cplusplus.com cplusplus.com
cplusplus.com   C++ : Forums : General C++ Programming : Unsigned char IO
  Search:
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forums
Forums
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programm...
Articles
Lounge
Jobs

-

question  Unsigned char IO

Mayflower (25)
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?
|
Zaita (1562)
in.get(&c); ?
| Last edited on
Mayflower (25)
Sadly, &c doesn't work, should i make c an unsigned char * ?
|
Duoas (1595)
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.
|

This topic is archived - New replies not allowed.
Home page | Privacy policy
© cplusplus.com, 2000-2009 - All rights reserved - v2.2
Spotted an error? contact us