//main.c
#include "fligh.h"
int main()
{
while(1)
{
Welcome();
char ch = getch();// 读取字符
switch(ch)
{
case '1':// 录入
Import_fligh();
break;
case '2':// 显示
break;
case '3':// 按要求查找
break;
case '4':// 信息排序
break;
case '0':// 退出
break;
}
}
return 0;
}
```c
```c
//fligh.c
#include "fligh.h"
// 欢迎
void Welcome()
{
printf("\tWelcome to Flight System\t\n");
printf("==========================================\n");
printf("[1]Import [2]Print [3]Find [4]Sort [0]Quit\n");
printf("==========================================\n");
}
// 录入航班信息
void Import_fligh()
{
// 创建一个新的节点
fligh_node *head = malloc(sizeof(fligh_node));
fligh *pnew = malloc(sizeof(fligh));
head->next = NULL;
// 头插法
if(head == NULL)
{
head = pnew;
}
else
{
head = head->next;
}
printf("输入航班号:\n");
scanf("%s",head->data.number);
printf("输入起点站:\n");
scanf("%s",head->data.staddress);
printf("输入终点站:\n");
scanf("%s",head->data.arraddress);
printf("输入班期:\n");
scanf("%s",head->data.date);
printf("输入机型:\n");
scanf("%s",head->data.type);
printf("输入起飞时间:\n");
scanf("%s",head->data.stime);
printf("输入到达时间:\n");
scanf("%s",head->data.atime);
printf("输入航票价:\n");
scanf("%s",head->data.price);
printf("信息录入成功\n");
system("pause");// 暂停
system("cls");// 清屏
}
```c
fligh.h
#ifndef __FLIGHT_H
#define __FLIGHT_H
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
typedef struct fligh
{
char number[10];// 航班号
char staddress[10];// 起点站
char arraddress[10];// 终点站
char date[10];// 班期
char type;// 机型
int stime;// 起飞时间
int atime;// 到达时间
float price;// 票价
}fligh;
typedef struct fligh_node
{
fligh data;
struct fligh_node *next;
}fligh_node;
//欢迎
void Welcome();
// 录入航班信息
void Import_fligh();
#endif
求大佬解答,应该是创建节点有问题,但是本人找不出来
```