What do you want to fix?
1 points to
9 8 7 6
^
and 2 points to
9 8 7 6
^
so both will read 8
as next int
.
Question
When using seekg, what parameter does seekg take. I read that it takes the position, but in the code below, using 1 or 2 for the seekg parameter gives the same result.
ifstream input ("numbers.in");
input.seekg(1);
int a;
input >> a;
cout << a;
Textfile is: 9 8 7 6
Whether I use 1 or 2 for seekg() I get 8. Why is this, and how do I fix it?
Solution
What do you want to fix?
1 points to
9 8 7 6
^
and 2 points to
9 8 7 6
^
so both will read 8
as next int
.