Howdy, Stranger!

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

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

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.