--- Quote Start ---
originally posted by mountain8848@Nov 9 2005, 10:10 AM
char test_char=-5;
printf("test_char %x,%x,%x\n",test_char,(char)test_char,(unsign char)test_char);
we expect the output was:
>test_char fb,fb,fb
but we got :
>test_char fffffffb,fffffffb,fb
why dose "char" variable have 4 bytes?
<div align='right'><{post_snapback}> (index.php?act=findpost&pid=10869)</div> --- Quote End ---
The char is converted to int by the printf. since 0xfb is a negative number, the resulting value is sign extended to 4 bytes, that is, 0xf...ffb
bye
Paolo