qq_曦正_0
2015-11-14 11:49
各位同学前辈,我这个代码运行显示正确,但是显示的都是乱码是怎么回事?
#include
int main()
{
char c = 97;
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;
}
显示结果:
/249/5117/8r7b/hello.c: In function 'main':
/249/5117/8r7b/hello.c:6:5: error: expected ',' or ';' before 'float'
float f = c //将c赋值给f
^
/249/5117/8r7b/hello.c:9:19: error: 'f' undeclared (first use in this function)
printf("%f\n",f);
^
/249/5117/8r7b/hello.c:9:19: note: each undeclared identifier is reported only once for each function it appears in
/249/5117/8r7b/hello.c:10:20: error: 'd' undeclared (first use in this function)
printf("%lf\n",d);
char是定义单个字符,用单引号引起来
输出语句后面要有分号
谢谢!
我怎么感觉你每个赋值后面应该是要加分号的吧
C语言入门
926210 学习 · 20797 问题
相似问题