|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
新手刚学到结构体,用VC6.0写了个简单小程序,记录学生基本信息。debug不出问题但运行出错,大神帮忙看一下好不好啊!
#include<stdio.h>
void main()
{
struct date
{
int month;
int day;
int year;
};
struct student
{
int num;
char name;
char sex;
struct date birthday;
double score;
}boy1, boy2;
printf("please input number: ");
scanf("%d", &boy1.num);
printf("please input name: ");
scanf("%s", &boy1.name);
printf("please input sex: ");
scanf("%s", &boy1.sex);
printf("please input score: ");
scanf("%lf", &boy1.score);
printf("please input birthday(MM): ");
scanf("%d", &boy1.birthday.month);
printf("please input birthday(DD): ");
scanf("%d", &boy1.birthday.day);
printf("please input birthday(YY): ");
scanf("%d", &boy1.birthday.year);
boy2 = boy1;
printf("Student Number = %d\nStudent Name = %s\nStudent Sex = %s\n", boy1.num, boy1.name, boy1.sex);
printf("Student Birthday = %d-%d-%d\nStudent Score = %lf\n\n", boy1.birthday.year, boy1.birthday.month, boy1.birthday.day, boy1.score);
printf("Student Number = %d\nStudent Name = %s\nStudent Sex = %s\n", boy2.num, boy2.name, boy2.sex);
printf("Student Birthday = %d-%d-%d\nStudent Score = %lf\n\n", boy2.birthday.year, boy2.birthday.month, boy2.birthday.day, boy2.score);
}
|
|