代碼顯示問題
各位同學前輩,我這個代碼運行顯示正確,但是顯示的都是亂碼是怎么回事?
#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);
2016-11-09
char是定義單個字符,用單引號引起來
輸出語句后面要有分號
2015-11-15
謝謝!
2015-11-15
我怎么感覺你每個賦值后面應該是要加分號的吧