#include <stdio.h>
int main()
{
char c = 'a';
int n = 'c'; //将c赋值给n
float f = 'c' ; //将c赋值给f
double d = 'c'; //将c赋值给d
printf("%d\n",n);
printf("%f\n",f);
printf("%lf\n",d);
return 0;
}
'c'代表的是字符类型,c是变量,这两个不一样。你是要把变量的值'a'赋给其他的n,f,d。
#include <stdio.h> int main() { char c = 'a'; int n = c; //将c赋值给n float f = c ; //将c赋值给f double d = c; //将c赋值给d printf("%d\n",n); printf("%f\n",f); printf("%lf\n",d); return 0; }
'c'是字符,这样输出会输出c