how to search through an external file
-
I have an external file in notepad(.txt) and I have many lines of records in it: example: my name is jim I have a car it is a beautiful day . . . If I want to store the next four lines start from "my name is jim" to an array of string class, how can I do it? I was trying to use strcmp to find line, but after I locate the line, I can only store one line into a string class. How can I store the following three lines into the string classes?
-
I have an external file in notepad(.txt) and I have many lines of records in it: example: my name is jim I have a car it is a beautiful day . . . If I want to store the next four lines start from "my name is jim" to an array of string class, how can I do it? I was trying to use strcmp to find line, but after I locate the line, I can only store one line into a string class. How can I store the following three lines into the string classes?
Either store each following line in its own string (i.e. have 3 different string objects), or concatenate the strings. e.g. std::string str = "my name is jim"; str += "\n" + getLineFromInputFile(); //...