visual studio 2013 - Displaying the ASCII characters in C without unsigned char -
unsigned char a; for(a=32;a<128;a=a+1) printf("%d='%c'\t",a,a); return(0);
why have put unsigned char? when left char, executed program , giving me infinite loop. shouldn't stop when a=127?
char
means either signed
or unsigned
depends on implementation. makes behaviour of code implementation defined.
seems on machine signed
. minimum , maximum value of signed char
-127
& +127
respectively per c standard. value greater 127
or less -127
can't assigned a
otherwise invoke undefined behaviour.
after a
reaches 127
, incremented 1 , value becomes 128
can't hold signed char
variable , hence code invokes undefined behaviour.
Comments
Post a Comment