If your code looks like this:
int i = 0;
while (! cin.eof()) {
cin >> x;
++i;
// work with x
}
Then you have an off by one error with the count i.
What you really need is:
int i;
while (cin >> x) {
++i;
// work with x
}