c - 键盘 c 没有 int 输入

标签 c input menu flush

我似乎无法让我的键盘接受输入,我也不知道为什么。我已经刷新了缓冲区(或者我认为我做到了),我得到的只是 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)

最佳答案

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

关于c - 键盘 c 没有 int 输入,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16227930/

相关文章:

c - 如何在 C 中跳过输入文件的第一行?

c++ - 在从 stdin 输入之前,我是否必须初始化 std::string?

android - 项目未显示在操作栏上

javascript - 使 "jsddm"菜单列出子菜单

Javascript - 如何在不清除输入的情况下更改标签的 innerText

c - C语言的生命游戏

c++ - 比较 if(...) 和 ? :,哪个更好?

c结构: Input requires number line by line by hitting "enter" after each number

android - 总是在android中下拉菜单

将函数作为参数传递给函数的 C 方法