-1

我似乎无法让我的键盘接受输入,我不知道为什么。我已经刷新了缓冲区(或者我认为我这样做了),我得到的只是 BCS。

这是我的菜单功能

//Menu
int menu() {
    int choice;

    do {
        printf("1)Move\n2)Display Maze\n3)Peek ahead\n");
        scanf("%i", &choice);
        while(getchar() != '\n');       
    } while(choice<=0 && choice>3);

    return choice;
}//end menu

这是我的主要内容。我先打印出迷宫然后显示菜单

printMaze(maze);
do
{
    choice = menu();     
    if(choice == 1)
    {
        //direction = readDirection();
        //move(maze, direction);
        printf("Hi\n");
    }// end choice

    else if(choice ==2)
        //displayMaze(maze);
        printf("Hello\n");
    else
        //peek(maze);
        printf("Goodbye\n");

} while(choice!=4);//hag doesn't kill me or i find the exit)
4

3 回答 3

0

您使用的是什么操作系统..,如果您是 Windows 版本,请尝试重新安装 turbo c++ 编译器并重新配置“TC”目录。

于 2013-04-26T03:12:21.223 回答
0

我对C不是很满意,但是....

您不应该在 While 循环中扫描 INPUT “INSIDE”吗?

while(getchar() != '\n');
  scanf("%i", &choice);
}while(choice<=0 && choice>3);
于 2013-04-26T03:34:11.320 回答
0

choice<=0 && choice>3->choice<=0 || choice>3

choice!=4// 1 <= choice<= 3,从不choice == 4

于 2013-04-26T09:25:04.877 回答