Unsigned char IO

1
2
3
4
5
        ifstream in;
	in.open(filename, ios::binary);

        unsigned char c;
        in.get(c);


The basic file input as listed in the tutorial will not accept unsigned chars, only chars or char*.

Help?
in.get(&c); ?
Last edited on
Sadly, &c doesn't work, should i make c an unsigned char * ?
That is a peculiarity of C and C++: char is distinct from both unsigned char and signed char. Just cheat with a little typecast.
1
2
unsigned char c;
in.get( (char)c );

That will still work properly.
Topic archived. No new replies allowed.