#include <stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct
{
int year;
int month;
int day;
}DATA;
struct emplyee
{
int num;
char name[20];
char sex;
DATA birthday;
char address[20];
}person[3];
void input (struct emplyee arr[],int n)
{
int i;
char temp[20];
for(i=0;i<n;i++)
{
fflush(studin);
gets(temp);
person[i].num=atoi(temp);
gets(person[i].name);
person[i].sex=getchar();
gets(temp);
person[i].birthday.year=atoi(temp);
gets(temp);
person[i].birthday.month=atoi(temp);
gets(temp);
person[i].birthday.day=atoi(temp);
gets(person[i].address);
}
}
void output (struct emplyee arr[],int n)
{
int i;
for(i=0;i<n;i++);
{
printf("%d%s%c%d%d%d%s\n",person[i].num,person[i].name,person[i].birthday.year,person[i].birthday.month,person[i].birthday.day,person[i].address);
}
}
main()
{
input(person,3);
output(person,3);
}
參考答案:printf函数第三各显示year应该为%d而不是%c