scanf的参数类型自动转换
#include <stdio.h>
int main()
{
int i;
char c;
for(i = 0; i < 5; i++)
{
printf("input: c = \t");
scanf("%d",&c);
printf("output: i = \t");
printf("%d \n", i);
printf("&c = %x",&c);
printf("\t&i = %x\n",&i);
}
getchar();
return 0;
}
运行过程:
(1)如下图示,c = 256时,i = 1; c = 512时, i = 2 ……
(2)遗留问题:当输入为字母时,如 d ,结果会怎样呢?!