标题:[求助]关于结构体数组的问题
取消只看楼主
boris250
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2007-9-11
 问题点数:0 回复次数:0 
[求助]关于结构体数组的问题
郁闷的,看的一午的书,再上练习,怎么调试都调不好,不知道哪里出了问题,高手帮忙指点!!!
#include<iostream>
#include<iomanip>
#include<string>
using namespace std;
struct Student
{
int num;
char name[10];
char sex;
int age;
float score[3];
}stu[2];
int main()
{
int k;
Student stu;
stu={101,"zhang",'M',19,95.5,64.0};
cout<<stu.num;
return 0;
}
错误提示:
Compiling...
number three.cpp
D:\c++\number three.cpp(17) : error C2059: syntax error : '{'
D:\c++\number three.cpp(17) : error C2143: syntax error : missing ';' before '{'
D:\c++\number three.cpp(17) : error C2143: syntax error : missing ';' before '}'
执行 cl.exe 时出错.

如果将Student stu;
stu={101,"zhang",'M',19,95.5,64.0};
改成Student stu={101,"zhang",'M',19,95.5,64.0};程序就不出错的,不知道这两者有什么区别。
搜索更多相关主题的帖子: 结构体 
2007-10-22 19:35



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-179872-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.741520 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved