#include main(){int a=0x7fffffff,b=025;float f1=123.456,f2=2.0;char c1,c2;cl='a';c2='b';printf("a=%d,b=%d\n",a,b);printf("c1=%c,c2=%c\n",c1,c2);printf("fi=%e,f2=%f\n",f1,f2);a=f1;b=f2;printf("a=%d,b=%d\n",a,b);}D:\课件\VC6\MyProjects\d\d.c(5) :warn

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 14:21:33
#includemain(){inta=0x7fffffff,b=025;floatf1=123.456,f2=2.0;charc1,c2;cl=''a'';c2=''b'';printf("a=%d,b=%

#include main(){int a=0x7fffffff,b=025;float f1=123.456,f2=2.0;char c1,c2;cl='a';c2='b';printf("a=%d,b=%d\n",a,b);printf("c1=%c,c2=%c\n",c1,c2);printf("fi=%e,f2=%f\n",f1,f2);a=f1;b=f2;printf("a=%d,b=%d\n",a,b);}D:\课件\VC6\MyProjects\d\d.c(5) :warn
#include
main()
{
int a=0x7fffffff,b=025;
float f1=123.456,f2=2.0;
char c1,c2;
cl='a';
c2='b';
printf("a=%d,b=%d\n",a,b);
printf("c1=%c,c2=%c\n",c1,c2);
printf("fi=%e,f2=%f\n",f1,f2);
a=f1;
b=f2;
printf("a=%d,b=%d\n",a,b);
}
D:\课件\VC6\MyProjects\d\d.c(5) :warning C4305:'initializing' :truncation from 'const double ' to 'float '
D:\课件\VC6\MyProjects\d\d.c(7) :error C2065:'cl' :undeclared identifier
D:\课件\VC6\MyProjects\d\d.c(12) :warning C4244:'=' :conversion from 'float ' to 'int ',possible loss of data
D:\课件\VC6\MyProjects\d\d.c(13) :warning C4244:'=' :conversion from 'float ' to 'int ',possible loss of data
执行 cl.exe 时出错.
哪里错了请大神指教呀

#include main(){int a=0x7fffffff,b=025;float f1=123.456,f2=2.0;char c1,c2;cl='a';c2='b';printf("a=%d,b=%d\n",a,b);printf("c1=%c,c2=%c\n",c1,c2);printf("fi=%e,f2=%f\n",f1,f2);a=f1;b=f2;printf("a=%d,b=%d\n",a,b);}D:\课件\VC6\MyProjects\d\d.c(5) :warn
错误是因为,你定义的char c1,你在下面赋值写的cl,所以error错误是 没有定义cl.至于你发的warning是警告,意思是float转int可能会损失精度.