これが私の主な機能です:
int main(int argc, char **argv)
{
LoadFile();
Node *temp;
char *key;
switch (GetUserInput())
{
case 1:
temp = malloc(sizeof(Node));
printf("\nEnter the key of the new node: ");
scanf("%s", temp->key);
printf("\nEnter the value of the new node: ");
scanf("%s", temp->value);
AddNode(temp);
free(temp);
break;
case 2:
key = malloc(sizeof(char *));
printf("Enter the key of the node you want to delete: ");
scanf("%s", key);
DeleteNode(key);
free(key);
break;
case 3:
PrintAll();
break;
case 4:
SaveFile();
break;
case 5:
return 0;
break;
default:
printf("\nWrong choice!\n");
break;
}
return 0;
}
唯一の問題は、case ステートメントが壊れた後、プログラムが終了することです。理由はわかりましたが、それを修正する方法がわかりません。caseステートメントの後でも、プログラムが毎回繰り返されるようにします。私はただ言うでしょうか:
main(argc, argv);
すべての break ステートメントの前に?