#include<iostream>
using namespace std;
#define MAXSIZE 4
typedef struct{
int sno;
char name[7];
int exp;
char q; //q表示这个人到没到的状态,按y或者n赋值
}stu[MAXSIZE];
int dianming() //2 点名及统计结果
{ int i,q; //点名
for(i=0;i<MAXSIZE;i++)
{ stu[i].exp=0;}
for(i=0;i<MAXSIZE;i++)
{ cin>>stu[i].sno>>"">>stu[i].name>>"">>stu[i].exp>>endl;
cout<<"点名开始:"<<endl;}
for(i=0;i<MAXSIZE;i++){
cout<<"stu[i].name\n";
q=getchar();
stu[i].q=q;
if (stu[i].q==y)
stu[i].exp=+10;
if (stu[i].q!=y)
stu[i].exp=-10;
if(i==MAXSIZE-1)
cout<<"点名完毕"<<endl; }
for(i=0;i<MAXSIZE;i++ ){
if(stu[i].q==n)
cout<<"未到学生:"<<"stu[i].name"<<endl; }
return 0;
}
int printsqlist(){ //4查看全部学生信息
int i;
for(i=0;i<MAXSIZE;i++)
{ cout<<"stu[i].sno"<<""<<"stu[i].name"<<""<<"stu[i].exp"<<endl;}
return 0;
}
int main()
{
int i, choose ;
cout<<"*************欢迎进入学院物联网工程班点名系统**********"<<endl;
cout<<"******************* ******************* *******************"<<endl;
cout<<"******************* ******************* *******************"<<endl;
//cout<<"1 开始导入名单"<<endl;
cout<<"1 点名及统计结果"<<endl;
cout<<"2 修改经验值"<<endl;
cout<<"3 查看全部学生信息"<<endl;
cout<<"9 退出点名系统\n"<<endl;
cout<<"请输入所要操作前的数字,按回车键确认:"<<endl;
cin>>choose;
switch(choose)
{
case 1:
cout<<"请输入全部学生学号姓名"<<"然后开始点名,到了输入y,未到输入n"<<endl;
dianming();break;
case 2: cout<<"请输入要修改经验值的学生的学号:"<<endl;
c=getchar();
for(i=0;i<MAXSIZE;i++){
if (stu[i].sno==c);
cout<<"修改经验值为"<<endl;
stu[i].exp=getchar();break;
case 3: printsqlist();break;
case 9: exit(0);break;
default: cout<<"输入错误,请输入列表中存在的序号!"<<endl;
}
}
return 0;
}
编译出错c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(17) : warning C4091: '' : ignored on left of 'struct [3]' when no variable is declared
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(17) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(17) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(19) : error C2275: 'stu' : illegal use of this type as an expression
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(9) : see declaration of 'stu'
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(19) : error C2228: left of '.sno' must have class/struct/union type
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(19) : error C2275: 'stu' : illegal use of this type as an expression
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(9) : see declaration of 'stu'
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(19) : error C2228: left of '.name' must have class/struct/union type
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(19) : error C2275: 'stu' : illegal use of this type as an expression
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(9) : see declaration of 'stu'
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(19) : error C2228: left of '.exp' must have class/struct/union type
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(24) : warning C4091: '' : ignored on left of 'struct [3]' when no variable is declared
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(24) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(24) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(25) : warning C4091: '' : ignored on left of 'struct [3]' when no variable is declared
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(25) : error C2143: syntax error : missing ')' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(25) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(25) : error C2059: syntax error : ')'
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(27) : warning C4091: '' : ignored on left of 'struct [3]' when no variable is declared
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(27) : error C2143: syntax error : missing ')' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(27) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(27) : error C2059: syntax error : ')'
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(32) : warning C4091: '' : ignored on left of 'struct [3]' when no variable is declared
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(32) : error C2143: syntax error : missing ')' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(32) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(32) : error C2059: syntax error : ')'
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(73) : error C2065: 'c' : undeclared identifier
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(75) : warning C4091: '' : ignored on left of 'struct [3]' when no variable is declared
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(75) : error C2143: syntax error : missing ')' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(75) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(75) : error C2059: syntax error : ')'
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(77) : warning C4091: '' : ignored on left of 'struct [3]' when no variable is declared
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(77) : error C2143: syntax error : missing ';' before '['
c:\users\computer1\desktop\vc++6.0_win8\common\msdev98\bin\111111111.cpp(77) : error C2143: syntax error : missing ';' before '['
执行 cl.exe 时出错.
------解决思路----------------------
typedef struct{ 不要 typedef'
------解决思路----------------------
typedef struct{ 不要 typedef
------解决思路----------------------
你这很多问题啊
typedef struct 不要typedef
里面的 y 和 n等是字符,你需要放在单引号里
case2中的c=getchar(); 你没定义c啊
还有你case2中大括号是不是没对应好
还有这句:cin>>stu[i].sno>>"">>stu[i].name>>"">>stu[i].exp>>endl; 你要表示cout还是cin,如果是cin你输入到endl干嘛
.......
你先改了这些看还有什么问题吧