You could also do something like this (makes the user list easier to update):
Code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
const char* users[] = { "mike", "brian", "jim", "bob", "joe", 0 };
bool found = false;
while(!found)
{
char name[20];
cout << "Enter username: ";
cin.getline(name, 20, '\n');
unsigned i = 0;
while(users[i] && !found)
{
if(strcmp(users[i], name) == 0)
found = true;
else ++i;
}
if(!found)
cout << "Incorrect user name, please re-enter user name" << endl;
}
cout << "correct... logging in..." << endl;
return 0;
}
-tf