注册 登录
编程论坛 新人交流区

在vc++运行这个程序错在哪里

hootoo55 发布于 2007-10-15 22:10, 314 次点击
#include<iostream.h>
void main()
{
struct Student
{
int no;
chart name[10];
chart sex;
struct Day
{
int year;
int month;
int day;
}birthday;
chart class;
}stud;
cout<<"输入一个学生信息"<<endl;
cout<<" 学号:";cin>>stud.no;
cout<<" 姓名:";cin>>stud.name;
cout<<" 性别:";cin>>stud.sex;
cout<<" 出生日期 年:";cin>>stud.birthday.year;
cout<<" 月:";cin>>stud.birthday.month;
cout<<" 日:";cin>>stud.birthday.day;
cout<<" 班号:";cin>>stud.class;
cout<<endl;
cout<<"输出一个学生信息"<<endl;
cout<<" 学号:"<<stud.no<<endl;
cout<<" 姓名:"<<stud.name<<endl;
cout<<" 性别:"<<stud.sex<<endl;
cout<<" 出生日期:"<<stud.birthday.year<<"年";
cout<<stud.birthday.month<<"月";
cout<<stud.birthday.day<<"日"<<endl;

}




用vc++运行
9 回复
#2
Standford2007-10-15 22:44
#include<iostream>
#include<string>
using namespace std;
void main()
{
struct Student
{
int no;
char name[10];
string sex;//性别要定义为字符串型,char只能表示单个字符
struct Day
{
int year;
int month;
int day;
}birthday;
string classes;//class为关键字,不能作为变量
}stud;
cout<<"输入一个学生信息"<<endl;
cout<<" 学号:";cin>>stud.no;
cout<<" 姓名:";cin>>stud.name;
cout<<" 性别:";cin>>stud.sex;
cout<<" 出生日期 年:";cin>>stud.birthday.year;
cout<<" 月:";cin>>stud.birthday.month;
cout<<" 日:";cin>>stud.birthday.day;
cout<<" 班号:";cin>>stud.classes;
cout<<endl;
cout<<"输出一个学生信息"<<endl;
cout<<" 学号:"<<stud.no<<endl;
cout<<" 姓名:"<<stud.name<<endl;
cout<<" 性别:"<<stud.sex<<endl;
cout<<" 出生日期:"<<stud.birthday.year<<"年";
cout<<stud.birthday.month<<"月";
cout<<stud.birthday.day<<"日"<<endl;
cout<<" 班号:"<<stud.classes<<endl;
}
这是我调试的,你看一下吧
#3
jiangchang2007-10-15 23:19
这个初始化过程好像有点不对吧
呵呵,我也是菜鸟,也不太懂。
#4
爱死了C2007-10-15 23:25
我也是菜鸟看不明白
#5
my_o02007-10-15 23:54
菜鸟顶贴,学习了
#6
hootoo552007-10-17 12:52

谢谢您啊

。。。。

不过你的程序好像不行啊??

#7
Mr_Wild2007-10-17 22:18
以下是引用Standford在2007-10-15 22:44:45的发言:
#include<iostream>
#include<string>
using namespace std;
void main()
{
struct Student
{
int no;
char name[10];这里分号改了
string sex;//性别要定义为字符串型,char只能表示单个字符
struct Day
{
int year;
int month;
int day;
}birthday;
string classes;//class为关键字,不能作为变量
}stud;
cout<<"输入一个学生信息"<<endl;
cout<<" 学号:";cin>>stud.no;
cout<<" 姓名:";cin>>stud.name;
cout<<" 性别:";cin>>stud.sex;
cout<<" 出生日期 年:";cin>>stud.birthday.year;
cout<<" 月:";cin>>stud.birthday.month;
cout<<" 日:";cin>>stud.birthday.day;
cout<<" 班号:";cin>>stud.classes;
cout<<endl;
cout<<"输出一个学生信息"<<endl;
cout<<" 学号:"<<stud.no<<endl;
cout<<" 姓名:"<<stud.name<<endl;
cout<<" 性别:"<<stud.sex<<endl;
cout<<" 出生日期:"<<stud.birthday.year<<"年";
cout<<stud.birthday.month<<"月";
cout<<stud.birthday.day<<"日"<<endl;
cout<<" 班号:"<<stud.classes<<endl;
}
这是我调试的,你看一下吧

#8
liwanlei2007-10-17 22:38
倒萨的
#9
hootoo552007-10-17 23:16

哈哈

楼上真细心。。

谢谢,,,,

#10
beiwei11212007-10-17 23:59
诶 标点符号 出错 是 新手 经常犯错误啊
1