Click here to Skip to main content
15,887,952 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionhow to assign unsigned char in c++? Pin
mathivanaan6-May-11 1:00
mathivanaan6-May-11 1:00 
AnswerRe: how to assign unsigned char in c++? Pin
Chris Losinger6-May-11 1:01
professionalChris Losinger6-May-11 1:01 
QuestionRe: how to assign unsigned char in c++? Pin
Niklas L6-May-11 1:18
Niklas L6-May-11 1:18 
AnswerRe: how to assign unsigned char in c++? Pin
CPallini6-May-11 10:18
mveCPallini6-May-11 10:18 
AnswerRe: how to assign unsigned char in c++? Pin
Stefan_Lang6-May-11 2:21
Stefan_Lang6-May-11 2:21 
AnswerRe: how to assign unsigned char in c++? Pin
Luc Pattyn6-May-11 2:43
sitebuilderLuc Pattyn6-May-11 2:43 
AnswerRe: how to assign unsigned char in c++? Pin
CPallini6-May-11 10:21
mveCPallini6-May-11 10:21 
AnswerRe: how to assign unsigned char in c++? Pin
mike@codeproject8-May-11 5:51
mike@codeproject8-May-11 5:51 
You are getting a 10 as a binary value with that assignment.

If you use cout<< to print it out, however, you won't see a 10. That's because cout<< called on a char or unsigned char value always treats the value as a character, not a number. What you will see is that the next thing you output will begin on a new line. The 10 translates to a '\n' newline character.

To see the binary value of a char as a unsigned decimal value, use a typecast first.
unsigned char bb = 10;
cout << "** bb looks like [" << bb <<] this." << endl;
cout << "** (unsigned)bb looks like: " << (unsigned)bb << endl;

Which should display:

** bb looks like [
] this.
** (unsigned)bb looks like: 10

I put the unsigned char version in [] brackets so you can see what the effect is on the output.

Cheers,
Mike
GeneralRe: how to assign unsigned char in c++? Pin
mathivanaan9-May-11 18:48
mathivanaan9-May-11 18:48 
Questionhow to pass values between dialog window in MFC Pin
lamrinraj5-May-11 23:55
lamrinraj5-May-11 23:55 
AnswerRe: how to pass values between dialog window in MFC Pin
Cool_Dev6-May-11 1:07
Cool_Dev6-May-11 1:07 
GeneralRe: how to pass values between dialog window in MFC Pin
lamrinraj9-May-11 1:56
lamrinraj9-May-11 1:56 
QuestionRe: how to pass values between dialog window in MFC Pin
David Crow9-May-11 3:54
David Crow9-May-11 3:54 
AnswerRe: how to pass values between dialog window in MFC Pin
Niklas L6-May-11 1:12
Niklas L6-May-11 1:12 
QuestionBall Physics Pin
Cyclone_S5-May-11 23:51
Cyclone_S5-May-11 23:51 
AnswerRe: Ball Physics Pin
Richard MacCutchan6-May-11 2:58
mveRichard MacCutchan6-May-11 2:58 
GeneralRe: Ball Physics Pin
Cyclone_S6-May-11 7:57
Cyclone_S6-May-11 7:57 
AnswerRe: Ball Physics Pin
CPallini6-May-11 10:29
mveCPallini6-May-11 10:29 
GeneralRe: Ball Physics Pin
Cyclone_S6-May-11 21:35
Cyclone_S6-May-11 21:35 
AnswerRe: Ball Physics Pin
Stefan_Lang10-May-11 5:11
Stefan_Lang10-May-11 5:11 
QuestionSetting BGColor to a WebBrowser Control [modified] Pin
pix_programmer5-May-11 1:32
pix_programmer5-May-11 1:32 
QuestionRe: Setting BGColor to a WebBrowser Control Pin
వేంకటనారాయణ(venkatmakam)5-May-11 1:54
వేంకటనారాయణ(venkatmakam)5-May-11 1:54 
AnswerRe: Setting BGColor to a WebBrowser Control Pin
pix_programmer5-May-11 2:17
pix_programmer5-May-11 2:17 
GeneralRe: Setting BGColor to a WebBrowser Control Pin
_Flaviu5-May-11 2:32
_Flaviu5-May-11 2:32 
GeneralRe: Setting BGColor to a WebBrowser Control Pin
pix_programmer5-May-11 2:34
pix_programmer5-May-11 2:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.