Getch() function - Programmers Heaven

Howdy, Stranger!

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

Categories

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...

Comments

  • AsmGuru62AsmGuru62 Posts: 6,519Member
    [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]
  • vibin_mdcpvibin_mdcp Posts: 60Member
    Alternatively you can make a call to system("PAUSE");

    system(const char*) is defined in cstdlib header file.
  • LundinLundin Posts: 3,711Member
    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.