c - Data types storage -
this question has answer here:
the following code prints 255, if assigned 0255 x, in second line, code prints 173!
is there explanation this?
void main() { unsigned long x = 255; /* unsigned long x = 0255;*/ unsigned char *ptr = &x; printf("%u",*ptr); getch(); }
when number has '0' in front of other digits, it's treated octal number. , 255 in octal 173 in decimal.
Comments
Post a Comment