So I was able to do part of a program, and only got stuck on one part. The program uses text input file to return things such as age and gender. However, The only thing that I couldn't get any output for was string name. For example, the input file had Joe Bob and the compiler returned your name is, but not Joe Bob. This is a hw questions so please hints only. I included <string> and all that other stuff. Like my book says, "it should read a string value from one line of an input file."
This is what I have:
string name;
cout << " Your name is " << name << endl;
getline(fin, name);
It is not clear your hw for me. I guess you have a file that contains some info:
Little Joe
28
male
Joe Bob
35
male
etc.
Moreover you need to get a name and you have to search this name in the file and print the other things besides name, doesn't it?
First you should read the name, secondly you should use the getline on every line in the file because of searching the particular name. You can do it in a loop. If you find it, you can read more data.
Thanks for the help!
@screw: those links were helpful :)
@Maese909: Yea in the end I think that is what was wrong and the first link screw posted verified that.