| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 405 人关注过本帖
标题:[求助]如果把一个链表存储到文件??
取消只看楼主 加入收藏
cen0225
Rank: 1
等 级:新手上路
帖 子:14
专家分:0
注 册:2007-9-28
收藏
 问题点数:0 回复次数:0 
[求助]如果把一个链表存储到文件??

主要代码:
#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",&current->No);

printf("\n请输入姓名:");
scanf("%s",current->Name);

printf("\n请输入性别:");
scanf("%d",&current->Sex);

printf("\n请输入生日(年 月 日):");
scanf("%d %d %d",&current->Birth.year,&current->Birth.month,&current->Birth.day);

printf("\n请输入籍贯:");
scanf("%s",current->Hometown);

printf("\n请输入学历:");
scanf("%d",&current->Education);

printf("\n请输入地址:");
scanf("%s",current->Address);

printf("\n请输入电话:");
scanf("%s",current->Phone);

printf("\n请输入工龄:");
scanf("%d",&current->WorkYears);

printf("\n请输入基本工资:");
scanf("%f",&current->BaseSalary);

current->next=NULL;
previous=current;
//save();

}
}

如何把输入的信息存储到文件,下次打开后再如何读取?

搜索更多相关主题的帖子: 链表 文件 
2007-10-25 08:50
快速回复:[求助]如果把一个链表存储到文件??
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015727 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved