1 typedef struct Data{
2 40 char *name;
3 41 char *IDCARD;
4 42 char *job_id;
5 43 char *length;
6 44 char *education;
7 45 char *marriage;
8 46 int local;
9 47 }Data;
10 48
11 49 typedef struct node{
12 50 Data *data;
13 51 struct node *next;
14 52 struct node *prior;
15 53 }node;
16 54
17 55 typedef struct doublelist{
18 56 node *head;
19 57 node *tail;
20 58 size_t size;
21 59 }doublelist;
22 60
 1  void inserttail2(node *newnode)
2 126 {
3 127 if(list->size == 0){
4 128 list->tail = newnode;
5 129 list->head = newnode;
6 130 }
7 131 else{
8 132 newnode->prior = list->tail;
9 133 list->tail->next = newnode;
10 134 list->tail = newnode;
11 135 }
12 136 list->size++;
13 137 }
14 void SaveInformation()
15 380 {
16 381 node *temp = list->head;
17 382 FILE *file = fopen("staff_information.txt","w");//进行追加写
18 383 if(file == NULL){
19 384 return;
20 385 }
21 386 else{
22 387 while(temp != NULL){
23 388 fprintf(file,"%s\t\t",temp->data->name);
24 389 fprintf(file,"%s\t\t",temp->data->IDCARD);
25 390 fprintf(file,"%s\t\t",temp->data->job_id);
26 391 fprintf(file,"%s\t\t",temp->data->length);
27 392 fprintf(file,"%s\t\t",temp->data->education);
28 393 fprintf(file,"%s\n\n",temp->data->marriage);
29 394 temp = temp->next;
30 395 }
31 396 fclose(file);
32 397 }
33 398 }
34 399
35 400 void ReadInformation()
36 401 {
37 402 node *temp = list->head;
38 403 FILE *file = fopen("staff_information.txt","r");
39 404 if(file == NULL){
40 405 return;
41 406 }
42 407 else{
43 408 while(!feof(file)){
44 409 node *newnode = creat_node();//此函数返回值就为一个新节点,这行代码大家可以不用在意
45 410 fscanf(file,"%s\t\t",newnode->data->name);
46 411 fscanf(file,"%s\t\t",newnode->data->IDCARD);
47 412 fscanf(file,"%s\t\t",newnode->data->job_id);
48 413 fscanf(file,"%s\t\t",newnode->data->length);
49 414 fscanf(file,"%s\t\t",newnode->data->education);
50 415 fscanf(file,"%s\t\t",newnode->data->marriage);
51 416 inserttail2(newnode);//t尾插法插入节点
52 417 }
53 418 fclose(file);
54 419 }
55 420 return;
56 421 }

附上creat_node代码原型

 1 node *creat_node(){
2 12 node *newnode;
3 13 newnode = (node *)malloc(sizeof(node));
4 14 newnode->data = (Data *)malloc(sizeof(Data));
5 15 if(newnode->data != NULL){
6 16 newnode->data->name = (char *)malloc(50 *sizeof(char));
7 17 newnode->data->IDCARD= (char *)malloc(50 *sizeof(char));
8 18 newnode->data->job_id = (char *)malloc(50 *sizeof(char));
9 19 newnode->data->length = (char *)malloc(50 *sizeof(char));
10 20 newnode->data->education = (char *)malloc(50 *sizeof(char));
11 21 newnode->data->marriage = (char *)malloc(50 *sizeof(char));
12 22 }
13 23 newnode->prior = NULL;
14 24 newnode->next = NULL;
15 25 return newnode;
16 26 }//创建一个新结点

大家照这个模板来就能解决大家的问题,顺式结构其实也几乎一样,希望能帮大家解决问题。

最新文章

  1. ASP.NET Core 1.0中实现文件上传的两种方式(提交表单和采用AJAX)
  2. js array push 添加内容
  3. ASP.NET MVC中使用FluentValidation验证实体
  4. ELK-Python(一)
  5. WPF——文本随滚动条改变而改变
  6. iOS的UILabel设置居上对齐,居中对齐,居下对齐
  7. Super Phyllis(穷举+搜索)
  8. Java与.net的区别delegate和event
  9. Jquery progressbar通过Ajax请求获取后台进度演示
  10. Q_DISABLE_COPY
  11. RMAN备份介质的移动与再恢复测试 [ catalog start with ‘dir’ ]
  12. 入坑IT十年(二)技术以外
  13. GPS坐标系
  14. Struts2,springMVC获取request和response
  15. Windows平台分布式架构实践 - 负载均衡(转载)
  16. MongoDB、Hbase、Redis等NoSQL分析
  17. js 求select option 的值和对应option的内容
  18. canvars 画花
  19. show point on image
  20. 异步FIFO跨时钟域亚稳态如何解决?

热门文章

  1. FZU 2129 子序列个数(DP)题解
  2. spring boot集成mybatis只剩两个sql 并提示 Cannot obtain primary key information from the database, generated objects may be incomplete
  3. historyReverser & array reverse
  4. css 设置多行文本的行间距
  5. input support upload excel only
  6. Flutter 设置input边框
  7. html2Canvas to Images
  8. 内核栈与thread_info结构详解
  9. linux 安装node和pm2
  10. Mybatis高级:Mybatis注解开发单表操作,Mybatis注解开发多表操作,构建sql语句,综合案例学生管理系统使用接口注解方式优化