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

  • General discussion

  • 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
        // 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
    echo // This code is contributed by neo123
    • Edited by mr mike17 Monday, February 17, 2020 5:17 PM
    • Moved by jrv Monday, February 17, 2020 7:23 PM off-topic
    Monday, February 17, 2020 5:16 PM

All replies

  • This is the Windows Powershell forum. Please ask your question in the appropriate forum.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Monday, February 17, 2020 6:12 PM