#include "stdio.h"
void main()
{
int i;
struct student
{
int stunum;
char name;
int birthdate;
char zhuanye;
}stu[2]={{6,"lujian",***********,"ie"},{4,"luyang",***********,"jixie"}};
for(i=0;i<4;i++)
printf("%d%s%d%s\n",stu[i].stunum,stu[i].name,stu[i].birthdate,stu[i].zhuanye);
}
提示出现错误,但不知道什么错
參考答案:#include <stdio.h>
int main()
{
int i;
struct student
{
int stunum;
char* name; // 改为char*或char name[10]
int birthdate;
char* zhuanye; // 同上
}stu[2]={{6,"lujian",***********,"ie"},{4,"luyang",***********,"jixie"}};
for(i=0;i<2;i++) // 这里改成2不然内存溢出
printf("%d%s%d%s\n",stu[i].stunum,stu[i].name,stu[i].birthdate,stu[i].zhuanye);