I have this program:
CODE:
#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;
}
}
}
Why can't it detect the Enter key? Am I doing anything wrong?
I tried everything I could find about it.
I tried using the value 10 (as said in the ASCII code), but nothing happens. Can someone tell me why?