ifstream fin;
ofstream fout;
char ch;
string st;
fin.open("testfile.txt");
fout.open("testfile.txt");
while(!fin.eof())
{
fin.get(ch);
cout << ch;
}
fin.clear();
fin.seekg(ios::beg);
while(!fin.eof())
{
getline(fin, st);
cout << st;
}
Test file contains the following:
abcd efg
1234 hij
result:
abcd efg
1234 hijabcd efg1234 hij
What I am asking is:
Why are the results different between reading with fin.get(ch) and getline(fin, st)?