while( std::getline( ifs, line ) && line.find(search_string) != 0 );
if( line.find(search_string) != 0 )
{
navData = "N/A" ;
}
else{
navData = line + '\n' ; // result initially contains the first line
// now keep reading line by line till we get an empty line or eof
while( std::getline( ifs, line ) && !line.empty() )
{
navData += line + '\n';
}
}
ifs.close();
return navData;
In Windows I get what I need:
1 2 3
A|BBBBB|1|2
R|RBBBB
R|RBBBB
In Mac, however, code "&& !line.empty()" seems to get ignored, since I get the following:
Get a debugger and watch the "empty" string in question, you may note that it actually has one character.
I guess that your issue is related to the different line break representation between OS http://en.wikipedia.org/wiki/Newline