I met a problem when I test the function printf:
First I write code like this:
int main(void)
{
char a = 'a';
printf("a = %f\n", a);
return 0;
}
The output is
And then I write code:
int main(void)
{
float b = 'a';
printf("b = %f\n", b);
return 0;
}
The output is
And then I write code:
int main(void)
{
char a = 'a';
float b = 'a';
printf("b = %f\n", b);
printf("a = %f\n", a);
return 0;
}
The output is
So I am confused why in the first program a = 0.000000 and in the third program a = 97.000000?
How does the function printf() work?
How does the symbol %f, %d work?
Aucun commentaire:
Enregistrer un commentaire