.seekg(-1,ios::cur);

Hi,

I am tring to use the the .seekg() to my pointer so that i can look at a previous character.
i import a file (which is saved to the varible infile

I was wondering if i can create a varible that can hold the value of this character so that i dont lose where the real pointer is in my program. I have tried with diffrent varible types but i get an error telling me that it cannont conver the type to .... (what ever type i tried)

infile.seekg(-1,ios::cur);

Thanks
Just use a char. I don't see how you could be getting an error.
thats what i though...
heres my error:

C2440: '=' : cannot convert from 'std::basic_istream<_Elem,_Traits>' to 'char'

i have

1
2
3
 char x = 0;

x = file.seekg(-1,ios::cur); 
seekg() doesn't return the character that's at the new position. You have to get it get() or peek().
Topic archived. No new replies allowed.