iofstream

I wrote this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
char operator[] (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!
It didn't work for me, for some reason. I got it to work anyway though.
thanks!
Topic archived. No new replies allowed.