getch problem

getch problem

Post by Enia » Fri, 06 Jun 2003 19:26:12


I have a problem with the following code. When the user do a choice the
following getchar() function returns imendiately. If i use getch() instead
(under windows) the program runs with no problem. Under Linux using UConio
library it doesn't work. As the getch() function is not an ANSI function ,
i'm wonder for another way to do the same think.
Anybody with any idea on this problem ?

#include <stdio.h>

int main(void) {
    int choice;
    do {
        printf("Your choice ?");
        scanf("%d", &choice);

        switch(choice) {
            case 1:
                 printf("Your choice is 1\n");
                 printf("press any key\n");
            case 2:
                 printf("Your choice is 2\n");
                 printf("press any key\n");
    } while (choice != 2);
return 0;


Thank you.

getch problem

Post by Kasper Dupon » Fri, 06 Jun 2003 19:33:26

Does this help?

Kasper Dupont -- der bruger for meget tid p? usenet.



1. Help getch problems

I have a problem with the getch function under linux.
If i use a statement like:

c = getch();

I would the screen to wait for the next user keypress and return
the value of it in c. What seems to happen under Linux is that
the user has to hit the key and then hit enter to continue.

Can alyone tell me what the workaround on this problem is
and why I am having this type of problem.

Thanks...   Paul

2. Adaptec 1522 & CD-Rom

3. getch() problem

4. interrupt/IO-APIC problems...

5. Problems using getch

6. Suggested values for limits.conf (login.defs)

7. problems with getch()

8. ISP connection slowdown after a couple of days

9. Curses: problem with getch while keypad is set

10. How do I do getch() or getchar() without pressing Enter

11. Writing a getch() function

12. getch() equivalent under linux?

13. getch/getchar/getc