Originally Posted by
Khabz
Considering you want to read the first 100 lines, you need to store each line in a variable. A vector would be the best solution.
So start by defining a vector and a string (line) so you can store each line in each vector's position.
If you wanted just a couple of lines, you'd be better off repeating the code you posted previously plus pushing the string into the vector, but considering you're willing to do it 100 times, just create a loop from 0 to 99/100, get each line of the file (getline) and push it back to the vector (myVector.push_back).