B
baumann@pan
hi all,
printf("%c",b) doesn't work properly.
#include <stdio.h>
int a , b;
char d, e;
char * p;
float f;
int main(int argc, char* argv[])
{
unsigned char a = 0;
printf("a:%d,b:%d,d:%c,e:%c,p:%p,f:%f\n",a,b,d,e,p, f);
return 0;
}
the prog runs with result as below
a:0,b:0,d:,e:,pnil),f:0.000000
if i run it in windows xp, i got
a:0,b:0,d:a,e:a,pnil),f:0.000000
why it can not printf char type variable d & e?
and if i change the printf statement to
printf("a:%d,b:%d,d:%x,e:%x,p:%p,f:%f\n",a,b,d,e,p, f);
a:0,b:0,d:0,e:0,pnil),f:0.000000
i got what i want.
but i would ask why? my answer to my question is since d, e are char
variable with value 0, maybe %c only print char which are readable char
such as '?','a-z' etc. but value 0 is not a readable char, so under
linux the printf("%c",0) would print nothing.
if my answer is right, why under windowz , it prints a?
printf("%c",b) doesn't work properly.
#include <stdio.h>
int a , b;
char d, e;
char * p;
float f;
int main(int argc, char* argv[])
{
unsigned char a = 0;
printf("a:%d,b:%d,d:%c,e:%c,p:%p,f:%f\n",a,b,d,e,p, f);
return 0;
}
the prog runs with result as below
a:0,b:0,d:,e:,pnil),f:0.000000
if i run it in windows xp, i got
a:0,b:0,d:a,e:a,pnil),f:0.000000
why it can not printf char type variable d & e?
and if i change the printf statement to
printf("a:%d,b:%d,d:%x,e:%x,p:%p,f:%f\n",a,b,d,e,p, f);
a:0,b:0,d:0,e:0,pnil),f:0.000000
i got what i want.
but i would ask why? my answer to my question is since d, e are char
variable with value 0, maybe %c only print char which are readable char
such as '?','a-z' etc. but value 0 is not a readable char, so under
linux the printf("%c",0) would print nothing.
if my answer is right, why under windowz , it prints a?