#include "listlib.c"
#include <conio.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
main()
{
char str[20], *sptr, *ptr;
Menu();
while(1){
printf("what you want to do: ");
scanf("%19s", str);
fflush(stdin);
sptr = str + (int)strspn(str, "\t ");
ptr = sptr = strtok(sptr, "\t ");
while (*ptr)
*ptr++ = tolower(*sptr++);
sptr = str + (int)strspn(str, "\t ");
if (!strcmp(sptr, "add")) Add();
else if (!strcmp(sptr, "alter")) Alter();
else if (!strcmp(sptr, "create")) Create();
else if (!strcmp(sptr, "delete")) Delete();
else if (!strcmp(sptr, "find")) (void)Find("find");
else if (!strcmp(sptr, "list")) List(stdout);
else if (!strcmp(sptr, "menu")) Menu();
else if (!strcmp(sptr, "quit")) Quit();
else if (!strcmp(sptr, "save")) Save();
else{
Menu();
printf("Please input right command\n");
}
}
}
Listlib.cÄ£¿é´úÂ룺
#include <string.h>
#include <stdlib.h>
#include <errno.h>
#include <conio.h>
#include <stdio.h>
#include <fcntl.h>
typedef struct{
char name[20];
char tel[15];
char *address;
char postcode;
}data_t;
typedef struct list_struct{
data_t this;
struct list_struct *next;
}list_t;
static list_t *headptr = NULL;
static list_t *tailptr = NULL;