locked
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


    • Moved by Dave PatrickMVP Monday, February 17, 2020 8:44 PM looking for forum
    Monday, February 17, 2020 8:31 PM

Answers

All replies

  • I'd try asking for help in PowerShell forum here.

    https://social.technet.microsoft.com/Forums/windows/en-US/home?forum=winserverpowershell

     

     



    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Monday, February 17, 2020 8:43 PM
  • thanks.

    i am new to here.

    Monday, February 17, 2020 9:13 PM
  • did you mean i should ask that question to them or look for an answer to that question without asking the question?
    Monday, February 17, 2020 9:15 PM
  • i asked the question there and it flaged me for spam and i found out to remove that error i need my acount to be verified. i know it gets rid of the error,but i  don't know why thats true, can you explain it to me?


    • Edited by mr mike17 Monday, February 17, 2020 10:17 PM
    Monday, February 17, 2020 9:24 PM
  • Only forum admins can verify accounts. The requirement is to prevent/reduce spam posts. You need to post a request to have your account verified in the current verification thread here:

    https://social.technet.microsoft.com/Forums/en-US/dc4002e4-e3de-4b1e-9a97-3702387886cc/verify-account-42?forum=reportabug

    The current verification thread periodically changes, but is always a sticky thread at the top of this forum:

    https://social.technet.microsoft.com/Forums/en-US/home?forum=reportabug

    The forum admins verify the accounts requested in the thread about twice per week.

    Edit: I found you post in the PowerShell forum. It is not flagged as spam. The message you got is misleading. But you still need to request verification in the thread I linked.

    But I also see the post was moved to the off-topic forum. I believe the PowerShell in the question title has thrown us off. I suspect the code is C++. I don't see how PowerShell would be involved. I don't know where you originally posted, but perhaps the question belongs in a C++ forum. I would ask here:

    https://social.msdn.microsoft.com/Forums/vstudio/en-US/home?forum=vcgeneral


    Richard Mueller - MVP Enterprise Mobility (Identity and Access)



    Monday, February 17, 2020 9:31 PM
  • did you mean i should ask that question to them or look for an answer to that question without asking the question?

    Ask if you cannot find an answer.

     

     




    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows Server] Datacenter Management

    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees, and confers no rights.

    Monday, February 17, 2020 9:39 PM
  • C and C++ are case sensitive. " Else" is not a valid keyword.

    Did you remember to include all the necessary headers?

    Tuesday, February 18, 2020 5:39 AM
  • i didn't before.

    i think i did.

    what exactly are my neccessary headers?

    i think it is

    #include set-location programname=dir
    using namespace std;

    am i right?

    Tuesday, February 18, 2020 3:17 PM