编译能过但是连接不能过,莫名其妙的错误???
# include <stdio.h># include <stdlib.h>
# define MAXWORDS 4
struct information {
char name[MAXWORDS];
int sex;
int years;
}human[10];
void inside_struct(struct information *p,int n);
void save_struct(char *fp,struct information *p,int n);
void outside_struct(struct information *p,int n);
void main()
{
struct information *q=&human[0];
//q=human;
char name_file[20];
inside_struct(q,10);
outside_struct(q,10);
printf("请输入您要保存的文件名\n");
gets(name_file);
save_sttruct(name_file,q,10);
printf("保存完毕,下次见!\n");
}
void inside_struct(struct information *p,int n)
{
int i;
printf("请输入%d位人员的信息,\n包括姓名,性别(0为男,1为女),年龄\n中间用空格隔开\n",n);
for(i=0;i<n;i++)
scanf("%s%d%d",&((p+i)->name),&((p+i)->sex),&((p+i)->years));
}
void outside_struct(struct information *p,int n)
{
int i=0;
printf("您所输入的信息如下:\n");
printf("姓名\t性别\t年龄\n");
for(;i<n;i++)
{
printf("%s\t",(p+i)->name);
if((p+i)->sex==0)
printf("男\t");
else
printf("女\t");
printf("%d",(p+i)->years);
putchar("\n");
}
}
void save_struct(char *fp,struct information *p,int n)
{
int i=0;
FILE *fpp;
printf("let's save the information\n");
if(fpp=fopen(fp,"w")==NULL)
printf("can't open the file\n");
for(;i<n;i++)
fprintf(*fp,"%s\t%d\t%d\t",(p+i)->name,(p+i)->sex,(p+i)->years);
printf("保存完毕,您可以打开查看");
}