Here's a Linux C program equivalent to the Windows pause command. It may give you an idea.
Code:
#include <unistd.h>
#include <termios.h>
#include <string.h>
int main()
{
printf("Press any key to continue.\n");
struct termios trm;
memset(&trm, 0, sizeof(struct termios));
cfmakeraw(&trm);
struct termios old;
tcgetattr(STDIN_FILENO, &old);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &trm);
char buf;
read(STDIN_FILENO, &buf, 1);
tcsetattr(STDIN_FILENO, TCSAFLUSH, &old);
return 0;
}
Note that cfmakeraw fills the termios structure with settings that put the terminal in "raw" mode: no echo and no waiting for a full line.
For your purposes, you'll want to get the old mode with tcsetattr, disable the ECHO bit in the c_lflag field, and set the modified attributes. To enable echo again, do the reverse. To be entirely correct, you should store the initial mode in the stream using the stream storage interface (now that's an interesting little beast - a good thing to learn about, even if its use is limited in general) and listen to the stream shutting down event (erase_event) to restore the original state. Otherwise, the program shutting down in no-echo mode might screw up your terminal, and you don't want that.
Of course all this applies only to POSIX. Windows is an entirely different matter. As we said, there's no portable way.