c语言实现链表和文件操作解决方案

c语言实现链表和文件操作
请各路英雄用看看这个题目,小弟在此先行谢过了。

设有一个单位的人员工资有如下信息:name、department、   base   pay、allowance、total。现从键盘输入一组人员工资数据并将它们存储到名为paydata的文件中;再从paydata取出工资数据并给每个人的base   pay增加100元,增加后将工资数据显示于屏幕(每行1人)。请编写能够完成上述工作的程序。用C语言的链表实现


------解决方案--------------------
/******************你运行下看看怎么样吧,我这边没有错误***************************/


#include "stdlib.h "
#include "stdio.h "
#define NUM 3
#define LEN sizeof(struct paycount)
struct paycount
{char name[20];
char department[20];
float basepay;
float allowance;
float total;
struct paycount *next;
};
int n;
struct paycount *creat()
{ struct paycount *head;
struct paycount *p1,*p2;
int i;
char ss1[10],ss2[10];;
n=-1;
head=0;
for(i=0;i <NUM;i++){
if (n==-1){
p2=p1=(struct paycount *)malloc(LEN);
}
else{
p2=p1;
p1=(struct paycount *)malloc(LEN);
}
printf( "name:\n ");
scanf( "%s ",p1-> name);
printf( "department:\n ");
scanf( "%s ",p1-> department);
printf( "basepay:\n ");
scanf( "%s ",ss1);
printf( "allowance:\n ");
scanf( "%s ",ss2);
p1-> basepay=atof(ss1);
p1-> allowance=atof(ss2);
p1-> total=p1-> basepay+p1-> allowance;
n=n+1;
if (n==0) head=p1;
else p2-> next=p1;
}
p1-> next=NULL;
return(head);
}


void prin(head)
struct paycount *head;
{struct paycount *p;
p=head;
while (p!=NULL)
{printf( "%s %s %6.1f %6.1f %6.1f\n ",p-> name,p-> department,p-> basepay,p-> allowance,p-> total);
p=p-> next;
}
}

int main()
{struct paycount *head;
FILE *fp;
head=creat();
prin(head);
fp=fopen( "c:\\paydata.txt ", "wb ");
while(head!=NULL){

fwrite(head,2,LEN,fp);
head=head-> next;
}
fclose(fp);
system( "pause ");
}