none
how do you get rid of the error: An expression was expected after. at line At line:27 char:14 in powershell? RRS feed

  • Question

  • (line 1.) C++ program to generate all possible
    >> // valid IP addresses from given string
    >>
    >>
    >> // Function checks whether IP digits
    >> // are valid or not.
    >> int is_valid(string ip)
    >> {
    >>     // Splitting by "."
    >>     vector <string> ips;
    >>     string ex = "";
    >>     for(int i = 0; i < ip.size(); i++)
    >>     {
    >>         if (ip[i] == '.')
    >>         {
    >>             ips.push_back(ex);
    >>             ex = "";
    >>         }
    >>         Else
    >>         {
    >>             ex = ex + ip[i];
    >>         }
    >>     }
    >>     ips.push_back(ex);
    >>
    >>     // Checking for the corner cases
    (line 27)     // cout << ip << endl;
    >>     for(int i = 0; i < ips.size(); i++)
    >>     {
    >>         // cout << ips[i] <<endl;
    >>         if( ips[i].length() > 3 ||
    >>             stoi(ips[i]) < 0 ||
    >>             stoi(ips[i]) > 255 )
    >>             return 0;
    >>
    >>         if( ips[i].length() > 1 &&
    >>             stoi(ips[i]) == 0)
    >>             return 0;
    >>
    >>         if( ips[i].length() > 1 &&
    >>             stoi(ips[i]) != 0 &&
    >>             ips[i][0] == '0')
    >>             return 0;
    >>     }
    >>     return 1;
    >> }
    >>
    >> // Function converts string to IP address
    >> void convert(string ip)
    >> {
    >>     int l = ip.length();
       return 0
    (line 53) echo // This code is contributed by neo123


    Monday, February 17, 2020 8:31 PM

Answers

All replies