This has been working fine on my system, but refuses to compile on a server that I've uploaded it to.

printf("Press <ENTER> to Continue\n\n");
while(getch() != 0x0d);

The error message that I get is: undefined reference to 'getch'

Any idea how to define getch and get this to compile?

Recommended Answers

All 3 Replies

Use getchar().

for(;;) {
use getchar()
if (the key is what you wanted) then break;
}

If this is a Linux/Unix program then you have to compile with -lcurses

gcc filename.c -o filename -lcurses

If this is a Linux/Unix program then you have to compile with -lcurses

gcc filename.c -o filename -lcurses

Why? getchar() is defined in stdio.h not curses.h. Oh wait a minute -- you were talking bout getch() which might be in curses. I don't think that's the one the op was talking about. He was referring to the one in conio.h which is a compiler-specific header file and AFAIK is not supported under *nix.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.