|How would I implement the specific format for the 1000 unique usernames?|
I am bit confused as to what you are asking here. Could you expand on this a bit more?
|And how would I get it to read the username then look up the corresponding ID number?|
Ok lets walk through this step by step.
The username will be repeatedly entered through istream object that gets passed into the function.
So once you have a username from the istream object you will want to search the entire document until your find that specified username (Or print error if you don't).
This is quite easy to do since all usernames are on their own seperate lines and are right at the front of each line. So all you need to do is read up to the first white space of the line into a variable to get the username.
Then we need to test that variable against the username you got from the istream object.
Finally if they match you print the corresponding ID number this will be just like with the username all you need to do is read up to the next white space.
So if that username on the line matches the istream username you would repeat the whole process again for the next istream username until you hit eof.
And if it doesn't match you just move onto the next line of the document and so on until you either find a match or hit the end of the document (Which you would print"Error").
Now remember this is just a broad overview of how it might
be done. That is the beauty of programming there are many ways to accomplish a task each with it's pros and cons. In my mind non of them are wrong so to speak.
For example you could read the file line by line or word by word to get the usernames to test and the corresponding ID's. Or a better way would be to read the whole file in the beginning of the function and store it in a container that you can then use to test usernames. The choice is up to you. Hope this helps a bit.