Here is how my file data is arranged
10 12 19 21 3
11 18 25 2 9
1 3 1
0 5 0
2 1 2
when i use getline() and istringstream to line by line strip the file, i am concerning to detect the blank line in between these two data blocks. I need to detect it not to skip it.
so i wrote
while(getline(fp1,line)){
if(line.empty()){
cout<<"empty line"<<endl;
}
it does not work. And i think maybe the line is empty but contains with white space so I wrote
while(getline(fp1,line)){
if(line == "\n"){
cout<<"empty line"<<endl;
}
not working. I even used line.find_first_not_of(' ') == std::string::npos as the condition, still no luck. Then i am thinking to print this blank space out to see what is in it.I printed all the length of my line, and i found the empty line has size 1. so then i wrote
if(line.length() == 1){
cout<<hex<< line;
}
i got a blank line back without anything.
I am confused. What am i suppose to do to detect this blank line? Please help!