Getch() function

hi Friends

I want to know one thing about getch() function. When we write the getch() function at the end of the C program then what character is taken from the keyboard by getch() function.? And what is the need of this?
pl... reply to this question soon.............. m waiting...


  • [color=Blue]getch() will return a character user types on the console.

    This function is not needed in completed application. This was added to stop before program ends so programmer can see the results on the console. Without it - the program ends and console closes too quickly to see anything. Instead of this approach - everyone should use a debugger and stop at the very end of main(), then switch to console and see the results.[/color]
  • Alternatively you can make a call to system("PAUSE");

    system(const char*) is defined in cstdlib header file.
  • Some comments:

    getch() is not standard C and will not work on most compilers.

    system() can be found in stdlib.h on a C compiler, and in cstdlib on a C++ compiler.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!