Forum Discussion
Altera_Forum
Honored Contributor
20 years agochar takes 4 bytes?
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,ffff...
Altera_Forum
Honored Contributor
20 years agoHi, paolo
Look the below codes, we got the result what we not expected, either.char test_char=-5;
unsigned char good=0xfb;
if(test_char==good){
printf("they are equal\n");
}else{
printf("they are not equal\n");
}
if(test_char==0xfb){
printf("test_char is 0xfb\n");
}else{
printf("test_char is not 0xfb\n");
} the result: >they are not equal >test_char is not 0xfb what should we do? As we should modify lots of codes what these error.