我在使用while循环和切换时遇到问题

时间:2019-12-07 13:43:38

标签: c

while(Game == 0)
{
    gotoxy(100,40);
    setForeColor(MY_COLOR_WHITE);
    printf("A- Jogar uma partida de Anabi\n");
    gotoxy(100,42);
    printf("B- Carregar partida anterior\n");
    gotoxy(100,44);
    printf("C- Descri%c%co do jogo\n", 135, 198);
    gotoxy(100,46);
    printf("D- Sair do jogo\n");

    scanf("%c", &choice);

    switch(choice)
    {

//This part of the code should break my loop

        case 'A':
        case 'a':
            gotoxy(100, 52);
            printf("Please enter your name bellow\n");
            gotoxy(98, 53);
            printf("->");
            scanf("%s",NamePlayer);
            Game = 1;
            break;

        case 'B':
        case 'b':
            // in here I am going to call a function, the function that reads the file previously saved
            //also here I am going to know if there is any saved files, and give an output to the user


            break;

        case 'C':
        case 'c':
//This gets me to the description of the game, rules, etc.. and its working fine with the loop

            DescricaoDoJogo();
            break;

        case 'D':
        case 'd':

            exit(0);
            break;

        default:
//This default is giving me trouble, should I use and If, else? Because when i choose the option C, and I get back to the menu what is inside the default executes

            printf("Wrong choice.. Try again.. A, B, C or D..");
            scanf(" %c", &choice);
            system("cls");
            break;
    }

}

0 个答案:

没有答案