我似乎無法讓我的鍵盤接受輸入,我不知道爲什麼。我沖洗了緩衝區(或者我認爲我做了),我得到的只是BCS。從鍵盤沒有int輸入c
這是我的菜單功能
//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)
什麼是* BCS *? 。 。 。 – 2013-04-26 02:49:13
@luserdroog閃爍的光標綜合症.....我在菜單顯示結束時縮小了它的位置。它實際上並沒有達到任何下面的代碼,但我不知道我在做什麼錯誤 – kevorski 2013-04-26 02:51:09
使用%d而不是%i ..參考http://bytes.com/topic/c/answers/484622-difference-between-scanf-i-scanf-d-maybe-bug-invs2005 – Mullaly 2013-04-26 02:51:39