Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
我对while循环和开关有问题 开关块中的break语句在开关循环时脱离了开关,但没有脱离封闭的循环。我刚刚发现,错误在scanf(“%s”,NamePlayer)中,我缺少一个“&”,就像这个scanf(“%s”,NamePlayer)。可能不是!如果N_C - Fatal编程技术网

我对while循环和开关有问题 开关块中的break语句在开关循环时脱离了开关,但没有脱离封闭的循环。我刚刚发现,错误在scanf(“%s”,NamePlayer)中,我缺少一个“&”,就像这个scanf(“%s”,NamePlayer)。可能不是!如果N

我对while循环和开关有问题 开关块中的break语句在开关循环时脱离了开关,但没有脱离封闭的循环。我刚刚发现,错误在scanf(“%s”,NamePlayer)中,我缺少一个“&”,就像这个scanf(“%s”,NamePlayer)。可能不是!如果N,c,C,我对while循环和开关有问题 开关块中的break语句在开关循环时脱离了开关,但没有脱离封闭的循环。我刚刚发现,错误在scanf(“%s”,NamePlayer)中,我缺少一个“&”,就像这个scanf(“%s”,NamePlayer)。可能不是!如果NamePlayer是char[]字符串,则隐含地址运算符。然后对简单的char变量使用“%s”格式(添加&)将导致未定义的行为。强烈建议从默认代码块中删除对scanf()的调用 while(Game == 0) { gotoxy(100

我对while循环和开关有问题
开关
块中的
break
语句在
开关
循环时脱离了
开关
,但没有脱离封闭的
循环。我刚刚发现,错误在scanf(“%s”,NamePlayer)中,我缺少一个“&”,就像这个scanf(“%s”,NamePlayer)。可能不是!如果
NamePlayer
char[]
字符串,则隐含地址运算符。然后对简单的
char
变量使用
“%s”
格式(添加
&
)将导致未定义的行为。强烈建议从
默认
代码块中删除对
scanf()
的调用
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;
    }

}