Hi I am just experimenting a little with typecasting and string formatting. Given the small program using MFC and compiled in Visual Studio Express.
[code]
short int i = 128;
char c;
CString str;
int len;
c = i; //move first byte of int to char.
str.Format("Value of char is %#X", c);
CClientDC dc(this);
len = str.GetLength();
dc.TextOutA(10,10,str,len);
[code]
when i = 127 the output is (as expected) 0X7F. However when i = 128 the output is 0XFFFFFF80. Where are all these F's coming from? Does it have anything to do with the CString class
Suddenly it appears that c is a 4 byte value. I understand that something (strange) should happen since char should only hold -128 to 127. But I would rather just expect 0X80 (binary 1000 0000). Which is what you get when i = -128.
Kind regards
Magnus