Important Concepts Programming

Getch() in C

We need a function in our program to enhance the feature of code reusability. A function contains a set of statements to make a small program. There are many predefined functions available in C which we can use in our program to make our program more better.

In this post, we will discuss a special type of predefined function getch(). We will try to learn getch() function using real as well as programming examples.

Getch() function in C

getch() function in C is a predefined function available in C program which is responsible for holding the output until any key is pressed.

In simple words, when we call getch() function in our main() function then it will hold the output so that we can check the output clearly. It will hold the output until any key is pressed using the keyboard.

Suppose a condition where we have to give our next input after checking the first output. Here we may use the getch() function to hold the output until we press any key to proceed further.

Syntax of getch() function

int main()

Example of getch() function

using namespace std;
int main()
    cout<<"Before Using getch\n";
    cout<<"Press any key :\n";
    cout<<"After using getch\n";


getch() in c


Leave a Reply

Your email address will not be published.