第17.5.7 小节代码 维护零件数据库改进版
//This is a comment
//Author:King
//Time:2020/12/11
//Reference:C Programming:A Modern Approach,Second Edition
/*******************************************************************************
17.5.7 小节代码 维护零件数据库改进版,使用有序链表的方法 链表由连续的结构体构成。
********************************************************************************/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
//#include <stdbool.h> // C99 only
//#include <time.h>
#include <stdlib.h>
#define NAME_LEN 25 //单词的最长长度
struct part{
//定义零件数据库结构体类型,采用链表结点的方式
int number; //编号
char name[NAME_LEN + 1]; //零件名称
int on_hand; //现有数量
struct part *next; //下一个结点
};
struct part *inventory = NULL; //初始化第一个元件为NULL
/* 函数声明*/
struct part *find_part(int number); //根据编号查找数组中零件信息
void insert(void); // 增加新零件
void search(void); // 搜索零件
void update(void); // 更新零件信息
void print(void); // 显示零件信息
int read_line(char str[], int n); //读入单词到数组
/*主函数*/
int main(void)
{
char code;
for(;;)
{