I was wondering if this can be accomplished using the ifstream library and using only a text file. Basically if I have multiple lines of information, regardless of whether or not they're the same length, would I be able to make my program read a specific line?
For example in the following file:
1 2 3
|
Bob Professor
Greg Singer Microphone Plane
Ed Runner Sun
|
If I wanted to read specifically line 2, aka the line starting with "Greg", is there a way to use markers to navigate to that line?
For example, is it possible to get to that line using the fact that it's the only one that starts with "Greg"? Or is there some kind of marker that I can place at some point in the lines to identify it? The desired result would be that so if I wanted to pull up a specific user's information from the text file (in this case, Greg), I'd be able to have the program read the information from that line.
Same thing if for example I wanted to pull up Ed, I'd just want it to read the line with Ed's info.
Any help would be greatly appreciated! Keep in mind, I can only use text files, so using another format is out of the question.