初学者求教怎么改
#include<stdio.h>#include <string.h>
#include<malloc.h>
#include<stdlib.h>
struct zhigong
{
unsigned number;
char name[15];
char sex;
int age[2];
char xueli;
int gongzi[6];
char dizhi[100];
int phone[15];
struct zhigong *next;
};
struct zhigong *adds()
{ struct zhigong *yuangong=(struct zhigong *)malloc(sizeof(struct zhigong));
if(yuangong!=NULL)
{ printf("Please input the number:");
scanf("%d",&yuangong->number);
printf("Please input the name:");
scanf("%s",&yuangong->name);
printf("Please input the sex(M or W):");
scanf("%s",&yuangong->sex);
printf("Please input the age:");
scanf("%s",&yuangong->age);
printf("Please input a degree(zhongzhuan(Z)dazhuan(D)benke(B)shushi(S)poshi(P):");
scanf("%s",&yuangong->xueli);
printf("Please input the wage:");
scanf("%d",&yuangong->gongzi);
printf("Please input the address:");
scanf("%s",&yuangong->dizhi);
printf("Please input the phone:");
scanf("%d",&yuangong->phone);
yuangong->next=NULL;
}
return(yuangong);
}
void add(struct zhigong **yuangong)
{ struct zhigong*yuangongs=adds();
if(yuangongs!= NULL)
{
if((*yuangong)!=NULL)
{
yuangongs->next=(*yuangong);
}
(*yuangong)=yuangongs;
}
}
struct zhigong *yuangong()
{return NULL;
}
void save(struct zhigong*yuangong)
{unsigned char filename[13];
printf("Please input the filename:");
scanf("%s",filename);
FILE *filesave; /*错误点1*//*错误点2*/
if((filesave=fopen("filename", "wb"))==NULL) /*错误点3*/
{
printf("Cannot open file %s!\n", filename);
return;
}
puts("Saveing ...");
yuangong=yuangong->next;
while(yuangong)
{
fwrite(yuangong,sizeof(struct zhigong),1,filesave);
yuangong=yuangong->next;
}
fclose(filesave);
puts("Saveing is finished!");
}
void load(struct zhigong *yuangong)
{char filename[13];
printf("Please input the filename:");
scanf("%s",filename);
FILE *fileload; /*错误点4*//*错误点5*/
if((fileload=fopen("filename","rb"))==NULL) /*错误点6*/
{printf("Cannot open file %s !\n", filename);
return;}
while(!feof(fileload))
{
fread(&yuangong,sizeof(struct),1,fileload);
yuangong=yuangong->next;
}
fclose(fileload);
return;
}
void main()
{char key;
int num;
char tiaojian;
help();
struct zhigong *yuangong;
create();
printf("\n=");
while((key=getchar())!='q'&&'Q'&&key!=27)
{switch(key)
{case'a':case'A':add(&yuangong);printf("Input success\n");getchar();break;
case'e':case'E':save(yuangong);getchar();break;
case'r':case'R':load(yuangong);getchar();break;
default: puts("Error command!");
}
}
getch();
}
编译环境:wintc 真心求教高手
错误1: typedef 符号使用不当在 save 函数中
错误2: 未定义的符号'filesave'在 save 函数中
错误3: typedef 符号使用不当在 load 函数中
错误4: 未定义的符号'fileload'在 load 函数中
错误5: 指针必需在 -> 的左侧在 load 函数中
错误6: 构造或联合语法错误在 load 函数中
错误7: 表达式语法错在 main 函数中