主要代码:
#include<stdio.h>
#include<stdlib.h>
#include<conio.h>
#include<ctype.h>
struct Date
{
int day;
int month;
int year;
};
struct Engineer
{
unsigned int No;
char Name[20];
unsigned int Sex;
struct Date Birth;
char Hometown[10];
unsigned int Education;
char Address[30];
char Phone[15];
unsigned int WorkYears;
double BaseSalary;
struct Engineer *next;
};
struct Engineer *first=NULL;
struct Engineer *current=NULL;
struct Engineer *previous=NULL;
void Input()
{
char test='\0';
system("cls");
for( ; ; )
{
printf("\n你想输入一个工程师的信息吗?(Y/N)");
test=getch();
if(tolower(test)=='n')
break;
current=(struct Engineer*)malloc(sizeof(struct Engineer));
if(first==NULL)
first=current;
if(previous!=NULL)
previous->next=current;
printf("\n请输入编号:");
scanf("%d",¤t->No);
printf("\n请输入姓名:");
scanf("%s",current->Name);
printf("\n请输入性别:");
scanf("%d",¤t->Sex);
printf("\n请输入生日(年 月 日):");
scanf("%d %d %d",¤t->Birth.year,¤t->Birth.month,¤t->Birth.day);
printf("\n请输入籍贯:");
scanf("%s",current->Hometown);
printf("\n请输入学历:");
scanf("%d",¤t->Education);
printf("\n请输入地址:");
scanf("%s",current->Address);
printf("\n请输入电话:");
scanf("%s",current->Phone);
printf("\n请输入工龄:");
scanf("%d",¤t->WorkYears);
printf("\n请输入基本工资:");
scanf("%f",¤t->BaseSalary);
current->next=NULL;
previous=current;
//save();
}
}
如何把输入的信息存储到文件,下次打开后再如何读取?