/*如有不足之處,還望各位多多指點.*/
#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);
<