【发布时间】:2014-01-24 07:47:54
【问题描述】:
我有这个程序:
代码:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
main()
{
char menitem[3][32];
int i = 0, key;
strcpy(menitem[0], "This is the first option.");
strcpy(menitem[1], "And I'm the second option.");
strcpy(menitem[2], "Don't forget me: The third option!");
start:
system("cls");
printf("%s", menitem[i]);
ret:
key = getch();
if(i == 0)
{
switch(key)
{
case 80: i++; goto start;
case '\n': puts("Enter"); getch(); goto start;
default: goto ret;
}
}
else if(i == 2)
{
switch(key)
{
case 72: i--; goto start;
case '\n': puts("Enter"); getch(); goto start;
default: goto ret;
}
}
else
{
switch(key)
{
case 80: i++; goto start;
case 72: i--; goto start;
case '\n': puts("Enter"); getch(); goto start;
default: goto ret;
}
}
}
为什么检测不到 Enter 键?我做错了什么吗?
我尝试了所有我能找到的。
我尝试使用值 10(如 ASCII 代码中所述),但没有任何反应。谁能告诉我为什么?
【问题讨论】: