读书人

书下例子这要如何修改

发布时间: 2012-08-25 10:06:20 作者: rapoo

书上例子这要怎么修改?
#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。
当然,后面有其它错误是由该错误引起的。学编程更要学会自己改错误。

读书人网 >C语言

热点推荐