Click here to Skip to main content
16,011,868 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: How to make ClientEdge at CDialog? Pin
vgrigor20-Feb-04 6:09
vgrigor20-Feb-04 6:09 
GeneralRe: How to make ClientEdge at CDialog? Pin
Prakash Nadar20-Feb-04 13:01
Prakash Nadar20-Feb-04 13:01 
GeneralTrying to convert int to a char Pin
elvis890020-Feb-04 2:50
elvis890020-Feb-04 2:50 
GeneralRe: Trying to convert int to a char Pin
Anonymous20-Feb-04 2:55
Anonymous20-Feb-04 2:55 
GeneralRe: Trying to convert int to a char Pin
elvis890020-Feb-04 3:08
elvis890020-Feb-04 3:08 
GeneralRe: Trying to convert int to a char Pin
J.B.20-Feb-04 3:30
J.B.20-Feb-04 3:30 
GeneralRe: Trying to convert int to a char Pin
Tim Smith20-Feb-04 4:23
Tim Smith20-Feb-04 4:23 
GeneralRe: Trying to convert int to a char Pin
Nirav Doshi20-Feb-04 4:22
Nirav Doshi20-Feb-04 4:22 
As a signed char is a 1 byte value (Range: -128 to 127), it can be used to hold values only within the range. The most significant bit (MSB) of the char variable is used to denote a negative or a positive value stored in it. If the MSB is ON (1), it means a negative value stored in the 7 bits remaining.

An unsigned char, on the other hand, can hold values ranging from 0 to 255.

An int is a 2 byte value (N.B.: In a 32-bit platform, it is a 4-byte value). Whichever way, if you're trying to store an int in a char variable, it will ONLY store the first byte (because char can only have a byte).

That means, if:
int n = 50;         //
char c = (char) n;  // This will properly store 50 in the variable c

But, if:
int n = 300;  // If you convert this to binary, you will get two (or four) bytes as 1 & 44 (or 0, 0, 1 & 44)
              // 300 = 00000001 00101100
char c = (char) n;  // This will only get the 1st byte, which will be 00101100, which will be 44
I hope this explains in detail.

Nirav

* Don't wish it was easier, wish you were better! *
QuestionMemory handling? Pin
wallyka20-Feb-04 2:13
susswallyka20-Feb-04 2:13 
AnswerRe: Memory handling? Pin
John M. Drescher20-Feb-04 2:40
John M. Drescher20-Feb-04 2:40 
AnswerRe: Memory handling? Pin
Nirav Doshi20-Feb-04 4:05
Nirav Doshi20-Feb-04 4:05 
General'core dump' on windows Pin
roel_20-Feb-04 2:09
roel_20-Feb-04 2:09 
GeneralRe: 'core dump' on windows Pin
Prakash Nadar20-Feb-04 6:02
Prakash Nadar20-Feb-04 6:02 
GeneralVisual .NET 2003 equivalent of .bsc file Pin
Franz Klein20-Feb-04 2:01
Franz Klein20-Feb-04 2:01 
GeneralMultiplexing video capture card Pin
carlomagno20-Feb-04 1:21
carlomagno20-Feb-04 1:21 
GeneralFunny C++ Pin
Almindra20-Feb-04 0:27
Almindra20-Feb-04 0:27 
GeneralRe: Funny C++ Pin
David Crow20-Feb-04 3:12
David Crow20-Feb-04 3:12 
GeneralRe: Funny C++ Pin
Almindra20-Feb-04 4:21
Almindra20-Feb-04 4:21 
GeneralRe: Funny C++ Pin
David Crow20-Feb-04 4:40
David Crow20-Feb-04 4:40 
GeneralRe: Funny C++ Pin
Tim Smith20-Feb-04 4:31
Tim Smith20-Feb-04 4:31 
GeneralRe: Funny C++ Pin
jbarton20-Feb-04 3:22
jbarton20-Feb-04 3:22 
Questionhow to open file Pin
Goh Hui Beng20-Feb-04 0:24
Goh Hui Beng20-Feb-04 0:24 
AnswerRe: how to open file Pin
rw10420-Feb-04 1:56
rw10420-Feb-04 1:56 
GeneralRe: how to open file Pin
Goh Hui Beng20-Feb-04 5:20
Goh Hui Beng20-Feb-04 5:20 
GeneralRe: how to open file Pin
rw10420-Feb-04 5:44
rw10420-Feb-04 5:44 

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.