getch problem

getch problem

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



Hello.

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");
                 getchar();
            break;
            case 2:
                 printf("Your choice is 2\n");
                 printf("press any key\n");
                 getchar();
            break;
        }
    } while (choice != 2);
return 0;

Quote:}

Thank you.
 
 
 

getch problem

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


Does this help?

http://www.daimi.au.dk/~kasperd/comp.os.linux.development.faq.html#te...

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

for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_);

 
 
 

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