#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#define MAX_STRING 256
#define CMD_MAX_LINE 5
struct list{
int key;
char name[MAX_STRING];
struct list *next;
};
char cmd_Add[CMD_MAX_LINE] = "add_";
char cmd_Del[CMD_MAX_LINE] = "del_";
char cmd_List[CMD_MAX_LINE] = "list";
int main()
{
char str[MAX_STRING] = {NULL};
char cmd[CMD_MAX_LINE] = {NULL};
struct list *header;
int key = 0;
int i;
header = NULL;
while(str[0] != '0'){
/*初期化*/
for(i = 0;i<MAX_STRING;i++){
str[i] = NULL;
}
/*
for(i = 0;i<CMD_MAX_LINE;i++){
cmd[i] = NULL;
}*/
printf("[menu]\n");
printf("cmd:add_*\n");
printf("cmd:del_*\n");
printf("cmd:list\n");
printf("End:0\n");
scanf("%s",&str);
for(i = 0;str[i] != '_'; i++){
cmd[i] = str[i];
}
cmd[i] = '_';
printf("cmd(str) = %s\n",cmd);
if(strcmp(cmd,cmd_Add) == 0){
printf("add:\n");
}
else if(strcmp(cmd,cmd_Del) == 0){
printf("del:\n");
}
else if(strcmp(cmd,cmd_List) == 0){
printf("list:\n");
}
else if(cmd[0] == '0'){
printf("終了\n");
}
else{
printf("もう一度入力してください。\n");
}
}
return 0;
}
0 件のコメント:
コメントを投稿