| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 776 人关注过本帖
标题:[求助]关于结构体数组的问题
取消只看楼主 加入收藏
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
快速回复:[求助]关于结构体数组的问题
数据加载中...
 
   



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

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