I am trying to parse a text files which has blank lines. The getline function is supposed to read blank lines and move on to the next lines. However, my text file is like this :
ABC.....
DEF......
HIJ......
I am able to reach the lines before the blank lines but not the line 'HIJ......' with getline. Here is my code
char *tmp1,*tmp2,*tmp4;
tmp4="http://";
fileread.get(tmp2,8);
while((strcmp(tmp2,tmp4)!=0) )
{
fileread.getline(tmp1,100);
cout<<"tmp1 is"<<tmp1<<"\n";
fileread.get(tmp2,8);
cout<<"tmp2 is"<<tmp2<<"\n";
}
There are about 15 non-empty lines in my text file before the blank lines and I am able to read everything in them properly. Once I reach the blank lines , both tmp1 and tmp2 are printed blank
Can anyone figure out what the problem is?