I'm looking for a way to check a string that a user inputs when prompted (let's take it to be a string variable "userinput") from an array of 10 other strings. So far I have:
while (userinput.empty()) //Check for empty input
{
cout << "Please enter your identity.\n"; //Identify user
getline(cin, userinput);
do //Check to see if user is the same as the string variable "user"
{
cout << "This user is either non existent or has access privileges revoked.\n"; //Wrong username!
cout << "Please re-enter the username.\n";
getline(cin, userinput);
}
while (user != userinput);
}
It can be seen though, that this only works for a single string variable "user". How would I change this for a string array?
The array itself is the following:
string arr[10] = {"Test1", "Test2", "Test3", "Test4", "Test5", "Test6", "Test7", "Test8", "Test9", "Test10"};
Please note: I'm not intending to use passwords, only usernames.