首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C语言 >

书下例子这要如何修改

2012-08-25 
书上例子这要怎么修改?#includestdio.hmain(){unin{float a char b int c}datadata.a13.2printf(

书上例子这要怎么修改?
#include"stdio.h"
main()
{
unin
{float a;
char b;
int c;
}data;
data.a=13.2;
printf("%f\n",data.a);
data.b='A';
printf("%c\n",data.b);
data.c=107;
printf("%d\n",data.c);
printf("%c,%d\n",data.b,data.c);
}



--------------------Configuration: helloc - Win32 Debug--------------------
Compiling...
helloc.cpp
D:\VC语言\helloc\helloc.cpp(5) : error C2065: 'unin' : undeclared identifier
D:\VC语言\helloc\helloc.cpp(5) : error C2143: syntax error : missing ';' before '{'
D:\VC语言\helloc\helloc.cpp(8) : error C2065: 'data' : undeclared identifier
D:\VC语言\helloc\helloc.cpp(9) : error C2228: left of '.a' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(10) : error C2228: left of '.a' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(11) : error C2228: left of '.b' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(12) : error C2228: left of '.b' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(13) : error C2228: left of '.c' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(14) : error C2228: left of '.c' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(15) : error C2228: left of '.b' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(15) : error C2228: left of '.c' must have class/struct/union type
D:\VC语言\helloc\helloc.cpp(16) : warning C4508: 'main' : function should return a value; 'void' return type assumed
执行 cl.exe 时出错.

helloc.exe - 1 error(s), 0 warning(s)


[解决办法]
unin,这个是union吧。。。 。。。
又,main前最好加个void或int,那样写不好
[解决办法]
注意看报错的问题。已经说的很清楚,D:\VC语言\helloc\helloc.cpp(5) : error C2065: 'unin' : undeclared identifier。
当然,后面有其它错误是由该错误引起的。学编程更要学会自己改错误。

热点排行