I'm writing an assessment tool that cross checks the name entered by a person with a list of names of known people blacklisted by me. So far I can only figure out how to compare a users entry with one name, effectively limiting my blacklist to one name. I'm new to C++ and would appreciate any assistance anyone can provide on the matter.
Here is my currently working code, which only lets me compare one name. Now I know I can continue adding if statements, but this can grow confusing when I have to add 30+ names to the list, and I'm sure there is a simple way of cross checking with a list in C++.
#include
#include
using namespace std;
int main()
{
char person[80];
cout << "Please enter your name: ";
cin >> person;
if (strcmp (person, "Merlin") == 0)
{
cout << "Your name has been blacklisted.";
}
else
cout << "\nYou have been accepted:" << person << endl;
cin.get();
cin.get();
return 0;
}
P.S. I have also been informed that I can add the blacklisted names to a text file, which would be called into the program and then crosschecked to see if any of the names in the text file match the user input, regardless on if they use capitals or not. I am so far not able to figure out how though, so any assistance you can provide would be greatly appreciated.