代碼顯示問(wèn)題
各位同學(xué)前輩,我這個(gè)代碼運(yùn)行顯示正確,但是顯示的都是亂碼是怎么回事?
#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; ??
}?
顯示結(jié)果:?
/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是定義單個(gè)字符,用單引號(hào)引起來(lái)
輸出語(yǔ)句后面要有分號(hào)
2015-11-15
謝謝!
2015-11-15
我怎么感覺(jué)你每個(gè)賦值后面應(yīng)該是要加分號(hào)的吧