Hi,
I am trying to write a function that reads in individual lines from a txt file and stores them in a string array. The function works correctly except for when it reads in blank lines. Example:
Function
ifstream flinput( "somefile.txt" )
string line;
while( getline(flinput, line) ) {
//Add line to array
So the problem is if the text file looks like so.
Line1 Some Text blar blar blar
\n
Line3 Some Text blar blar blar
\n
Line5 Some Text blar blar blar
The array ends up looking like this.
array[0] = "Line1 Some Text blar blar blar"
array[1] = "Line3 Some Text blar blar blar"
array[2] = "Line5 Some Text blar blar blar"
When it should look like this.
array[0] = "Line1 Some Text blar blar blar"
array[1] = ""
array[2] = "Line3 Some Text blar blar blar"
array[3] = ""
array[4] = "Line5 Some Text blar blar blar"
What am I doing wrong?
Thanks