思路就是这样的 我这代码哪写错了
#include <stdio.h>#define N 3
struct stuent_info
{
char name[10];
int age;
char address[10];
}student[N], *stu_in, *stu_write;
void main()
{
stu_in = student;
stu_write = student;
void in (struct stuent_info student[]);
void save (struct stuent_info student[]);
in (student);
save (student);
}
void in (struct stuent_info student[N])
{
int i = 0;
for (i = 0; i < N; i++, stu_in++)
{
printf ("\nNo.%d学生的姓名 : ", i+1);
scanf ("%s", stu_in -> name);
printf ("年龄 : ");
scanf ("%d", stu_in -> age);
printf ("地址 : ");
scanf ("%s", stu_in -> address);
}
}
void save (struct stuent_info student[N])
{
FILE *fp;
int i = 0;
fp = fopen ("stu_list", "w");
for (i = 0; i < N; i++, stu_write++)
{
fwrite (stu_write, sizeof (struct stuent_info), N, fp); //&student[i]:输出数据的起始地址.
}
fclose (fp);
}