reading text files

how would i make a program that:
-reads a text file
-user inputs a string
-looks for that string phrase and prints the rest of that line
Text file:
1
2
3
Ape 5 // just prints 5 when ape is entered
Boy 10 // 10
Dog 11 // 11 
Reading from text file: http://www.cplusplus.com/doc/tutorial/files/
User input, and output: http://www.cplusplus.com/doc/tutorial/basic_io/

Break the problem down, do it slowly, get each step working first.

Start with reading from the file and outputting every line. Then you're halfway there.

I wouldn't bother doing it in that order.
I would ask the user for the string, then read thru the text file line by line, producing the output.

Way easier that way.

Are you required to read the whole file before asking about it?
Topic archived. No new replies allowed.