charoperator[] (int pos)
{
int counter = 0; char temp;
inFile.get(temp);
while (!inFile.eof())
{
if (counter > pos)
break;
inFile.get(temp);
++counter;
}
if (counter != pos) {temp = 0;}
return temp;
}
as a part of a class. it's supposed to return the char at index pos in a file. I keep getting an extra tab when I do this while loop. say the text is "abcde", it reads it as it's "abcdee", and I don't understand why.
Can anyone help? thanks!