jeudi 18 février 2016

Ask name, if wrong ask again, if right, keep going ( Not working ) C++

thats my code, what i'm trying to do here is a code that Ask for a name ( like a pass ) if the name is wrong, then the program says those 3 message errors and ask the name again, until one of the 2 white-listed names is given, then just keep going with the codes

int main(void)
{
setlocale(LC_ALL, "Portuguese");
string Name = "";
cout << "Whats your name dude ?" << endl;
cin >> Name;

if (Name == "ighor" ||
    Name == "indio")
    {
    cout << "Welcome friend =D" << endl;
    system("pause");
    system("cls");
    }
    else
    {
        do  
        {
            cout << "Sorry, wrong name =[" << endl;
            system("pause");
            system("cls");
            cout << "I'll give you another chance =]" << endl;
            system("pause");
            system("cls");
            cout << "Write your name again" << endl;
            cin >> Name;

            if (Name == "ighor" ||
                Name == "indio")
            {
                continue;
            }

        }   while (Name != "ighor" ||
                   Name != "indio");


    }

cout << "Whats up" << Name << endl;
system("pause");
system("cls");      
        return 0;

} My tests with this code gave me this : If i put a white-listed name ( indio or ighor ) i get the massage of correct name "Welcome friend =]". If i put a wrong name, i get the massage of wrong name, nice, then i'm asked to put the name again, i put one of the white-listed names and it keep saying that it's the wrong name, wrong names also show wrong name massage.

Aucun commentaire:

Enregistrer un commentaire