S
solartimba
I am having a file I/O problem that I can't seem to solve. The
following code is used to read in a file and write the same data:
CODE
while(infile)
{
infile >> num1 >> num2;
cout << num1 << " " << num2 << endl;
outfile << num1 << " " << num2 << endl;
}
INFILE
1 11
2 22
3 33
4 44
5 55
6 66
7 77
OUTFILE
1 11
2 22
3 33
4 44
5 55
6 66
7 77
77
Why is this repeating half of the final line of data?
following code is used to read in a file and write the same data:
CODE
while(infile)
{
infile >> num1 >> num2;
cout << num1 << " " << num2 << endl;
outfile << num1 << " " << num2 << endl;
}
INFILE
1 11
2 22
3 33
4 44
5 55
6 66
7 77
OUTFILE
1 11
2 22
3 33
4 44
5 55
6 66
7 77
77
Why is this repeating half of the final line of data?