I am trying to read strings from a file with contents like:
r FFFF
r FF
r FFFF
Here is my code:
int main ()
{ int a; ifstream ifile;
ifile.open("hi.txt");
while (!ifile.eof())
{
ifile.getline(data, 100); // read a line from file
a = strlen(data);
cout<<'length"<<a;
}
}
I am getting unexpected outputs: length7length5length6
.
What am I doing wrong?