while(true) {
getline(myfile, a[i]);
if (a[i]=="")//or if(a[i].empty())
break;
i++;
n = i;
}
In this while loop, when getline
function gets a blank line from myfile
object (there is a blank line between a series of binary numbers).
Example:
101010
000
11
1
00
<- when getline meets this line, by "if" break; has to work.
0011
10
00111
1101
But, it doesn't realize that blank line.
What is wrong?
What should I code to break when getline()
meets the blank line?
I do this through PuTTY.
You are most likely running into the NL/CR issue.
Instead of
Use something like:
where
You can also convert the file into a file with UNIX style line endings by using a utility called
dos2unix
. That should also fix the problem.