vendredi 6 septembre 2019

skip the whole loop without running the while

I have a while loop and I want to skip the whole loop without running the condition in parantheses again becuse as you now, the vector's Size is one greater then their cell number. I mean it is like:

[ Cell 0 ][ Cell 1 ][ Cell 2] --> Size = 3

So I have to skip the whole loop to prevent an Error. I need to write something that takes the program from point A to B without running "while()" My loop:

    size = 0;
    while ((usernamelog[size] != usrlog || passwordlog[size] != passlog) && size < usernamelog.size())//Checking Username And Password
    {
        if (x == 2)//Login Unsuccessfull
           cout << "Username or Password is Incorrect. Please try again." << endl;
        cout << "Enter Your Username: ";
        cin >> usrlog;
        cout << "Enter Your Password: ";
        cin >> passlog;
        x = 2;
        size++;
        if (usernamelog.size() == size)
           //Point A
    }

    //Point B

for example, when usernamelog.size is 2 and size is 2, Jump From A to B

Aucun commentaire:

Enregistrer un commentaire