Read from a file of names? Input Validation?

Hi. This is an assignment I have and need some help with...any thoughts?
Do Not Fly List
Write a program to be used by TSA officials to bar people from flying if their name appears on the "Do Not Fly List". For the list, use the names given in the file at http://www.mcs.csueastbay.edu/~tebo/Classes/2360/Sp14/names.txt.

Write a C++ program that reads the file into an array at startup. The program should then enter a loop that

asks the user for a name,
searches the array for a match,
prints a message indicating if the name was found or not,
asks the user if she wants to enter another name, and if so, repeats the loop, else exits it.

Submit only your source code (.cpp file) on Blackboard. (If for extra credit, use Binary Search (and a sort on file load).)

I know this requires fstream header and member functions...along with a user input validation sequence...I just don't know how to write a code to read the list, and check if the user entered name matches a name from the list as a whole?
It isn't clear at what stage you are getting stuck. If you need help with Reading from a file, you can find that here: http://www.cplusplus.com/doc/tutorial/files/
If you're not sure how to use arrays, then there's information here: http://www.cplusplus.com/doc/tutorial/arrays/
If you show the code you've done so far, it might be clearer where you are going wrong.

... But it's almost valid, drop the final '.'
Ah... yes )
Last edited on
How would I have Microsoft Visual Studio open a file that is a web page? . . . and furthermore, read the user-inputted first and last name, see if it matches a name on the "file," and is this even array related? I am beyond stuck...my book doesn't give any examples on such a situation.
How would I have Microsoft Visual Studio open a file that is a web page?
In this case, that isn't necessary. Instead save a copy of the file to your own computer hard drive and then get your program to read that.

As for your other questions, please show the code you have written so far, in order that we can see where you are having problems.
There is a tutorial page on file I/O here:
http://www.cplusplus.com/doc/tutorial/files/

is this even array related?
The original post said, "Write a C++ program that reads the file into an array at startup." so it looks like it is.

The thing about any problem like this, is to break it down into smaller steps, don't worry too much about the whole - by the time you've completed each step, the whole thing will be pretty much complete. Though at that stage you will need to test it and make changes to the code depending upon the results of your testing.

There's lots of help available here, you're not being ignored. But this has to be done as a cooperative effort, you need to do show show far you've got, and be very very specific about what problems you have.
Last edited on
Topic archived. No new replies allowed.