/*如有不足之处,还望各位多多指点.*/ #include <stdio.h> #include <string.h> #include <stdlib.h>
#define IN 1 #define OUT 0 #define FNAME "请输入药品名称(或编号):n" #define SNAME "请输入药品名称或编号(按-1结束):n" #define MENU "************************n" "1 - 添加药品信息.n" "2 - 删除药品信息.n" "3 - 按药品名称或编号查找.n" "4 - 更新我的药品信息.n" "5 - 计算购买药品总额.n" "6 - 打印我的药品列表.n" "7 - 退出.n" "************************n" "请选择: "
struct list_stag {//药品信息 char number[50]; char name[30]; char product[50]; float price; int amount;
struct list_stag *next; };
int GetDigit(const char *numstr); char *GetString(const char *putstr, char *gestr); struct list_stag *Insert(struct list_stag *fst, const struct list_stag *dst); struct list_stag *Delete(struct list_stag *fd, const char *destr); struct list_stag *SearchList(struct list_stag *serlist, const char *serstr); struct list_stag *Upated(struct list_stag *ulist, int *t, int sign); struct list_stag *GetValue(struct list_stag *ref); float PayList(struct list_stag *palist, char *s); void Print(const struct list_stag *fp); void PrintList(const struct list_stag* pst); void PayPrint(const char *str, float total); void FileSave(FILE *fPtr, const struct list_stag *f);
main() { FILE *file = fopen ("Medicine.DAT", "a+"); struct list_stag *list = NULL; struct list_stag red, *temp; int choice, i; float value, money; char string[3000];
while (fread(&red, 1, sizeof(struct list_stag), file))//读取文件信息 list = Insert(list, &red);
<
|