E
Enrico `Trippo' Porreca
Suppose I wanted to print an unsigned char (in hex). Should I say:
unsigned char x = 0x12;
printf("%X\n", x);
or
printf("%X\n", (unsigned) x);
?
If understand it correctly, x is converted to int (if int has a suitable
range of values), because I'm passing it to a variadic function.
I read different words in my C89 and C99 drafts: in the former, "%X"
wants an int, while in the latter it needs an unsigned int.
So the is cast needed in C99? If so, will the program be illegal in C89?
unsigned char x = 0x12;
printf("%X\n", x);
or
printf("%X\n", (unsigned) x);
?
If understand it correctly, x is converted to int (if int has a suitable
range of values), because I'm passing it to a variadic function.
I read different words in my C89 and C99 drafts: in the former, "%X"
wants an int, while in the latter it needs an unsigned int.
So the is cast needed in C99? If so, will the program be illegal in C89?