|
-
June 16th, 2011, 10:20 AM
#1
filestream to read and write integer numbers
Hi,
I wrote a small program, which uses filestream to read and write integer numbers. The segment of code is as following:
int i, j;
while (!from.eof()) { // from is the input file
from >> i >> j;
std::cout << i <<j;
}
The input file includes int numbers 1 2 3 4. I expected that the output is 1 2 3 4. But it turns out to be 1 2 3 4 3 4.
I can't figure out why it produces wrong result. Can someone give some ideas?
Thanks!
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|