Hi,
What command/code do I need to get input from a text file to
a) read the first n lines
b) read until certain characters
c) read until the end of the file?
Thanks
The tutorial is a bit dated but it will teach you what you need to know. Just keep in mind that there is generally no reason to ever use .open() or .close().
Looping on eof() is almost never a right choice. It works too late. EOF is set only after stream could not provide character it was asked.
You should always loop on input operation. Alternatively you should check for error condition immediately after read and before actually using value you got, as it might be invalid.
For b and c you should provide more use cases: what to do with stuff read from file in c? Is there one character or sequence of characters in b? What to do with characters before searched, after and searched for characters?
Most of these problems are solvable in two ways: first, long and hard: read file character-by-character and im[plement searching yourself; or second: use standard library and solve almost everything in one line.