What is the purpose of getch (); function in C?

I am new to the world of programming but there is always a similar syntax ending with getch (); What is it?

  • Aqs Malhotra
  • Aqs Malhotra
  • |
  • 16 Aug
  • |
  • 175257 Views
  • |
  • 441 Answers

text limit upto 4000

  • 18

    Well as you know, getch() reads a single byte character from input. getch() is a way to get a user inputted character. It can be used to hold program execution, but the "holding" is simply a side-effect of its primary purpose, which is to wait until the user enters a character.

    getch() and getchar() are used to read a character from screen.
    putch() and putchar() are used to write a character to screen.

    getch() and putch() are non-standard functions defined in conio.h, mostly used in turbo C/dev C++ environement. getchar() are putchar() are standard functions defined in C standard and they can be used in all environments.

    Yes, you can certainly write a program without these 4 functions. Actually in most of production software, programs are written in UNIX like environment so these are very rarely used.

    If you are using turbo C/dev C++, in that case you need to make output console wait for sometime in order to see the output. getch() or getchar() wait for user to press a key so that they can read the character and this allows you to see the output. Same effect can be achieved by using getche() function.

    • Voted By:
    • Saravanakumar ,
    • Mayur ,
    • Nagesh ,
    • Yash ,
    • Kadali ,
    • Bhavani ,
    • Rahul ,
    • Divya ,
    • Irfan ,
    • Swati

  • 9

    the getch(); function is used to hold the output screen for a while in the sense till any key is pressed

    • Voted By:
    • Khan ,
    • SHAGUN ,
    • Shimbhes ,
    • Shivangi ,
    • Jeetu ,
    • Sumera ,
    • Mihir ,
    • Amit ,
    • Dheeraj

  • 4

    wait the input from the keyboard and holding the screen.................

    • Voted By:
    • Mihir ,
    • Sandeep ,
    • Anil ,
    • Krishna ,
    • Rahul

  • 3

    Getch() is used to read the charecters from the screen

    • Voted By:
    • Mihir ,
    • Anil ,
    • Aditya ,
    • Shakshi

  • 3

    Well as you know, getch() reads a single byte character from input. getch() is a way to get a user inputted character. It can be used to hold program execution, but the "holding" is simply a side-effect of its primary purpose, which is to wait until the user enters a character.

    • Voted By:
    • Anil ,
    • Ved ,
    • Shakshi

  • 2

    getchh() pramots the user to press character and the character isnt printed on screen,getch header file is conio.h

    • Voted By:
    • Shimbhes ,
    • Anil

  • 2

    getch() function is used to provide an acknowledgement for characters.

    • Voted By:
    • Anil ,
    • Rajesh

  • 1

    getch() is simply a function makes a user to press a character and the character is not printed on the screen, getch is included in conio.h header file. This function does not comes under any standard library in C Language.

    • Voted By:
    • Shimbhes

  • 1

    to hold the output screen

    • Voted By:
    • Desh

  • 1

    Getch() function is need to be used in some c compilers like turbo c. Getch is used to hold the output sceen and wait until user gives any type of input(i.e. Until user press any key ) so that they can read the character and due to this we able to see the output on the screen. This task can also be performed by using getche() or getchar(). Note that dev c++ does not need getch() funtion to hold its output screen.

    • Voted By:
    • Priyesh

  • 1

    getch() is used to read the charecter from screen.by this capability it also holds the output screen.in some c editors the output will not be displayed after perfect execution it just blinks at that time getch() is most useful to see the output

    • Voted By:
    • Anil

  • 1

    By using this function we can read a character directly from the keyboard. Generally getch() are placing at end of the program after printing the output on screen.

    • Voted By:
    • Abhiram

  • 1

    to get the output of a program

    • Voted By:
    • Mahesh

  • 1

    to hold a output on screen

    • Voted By:
    • More

  • 1

    getch() is used to make the screen stop ..till you press any button.

    • Voted By:
    • Shubham

  • 1

    it holds the output console window, till the user feed input or press any key !

    • Voted By:
    • Gaurav

  • 1

    wait for any input (press any button of key) from keyboard.

    • Voted By:
    • Gaurav

  • 0

    Program educated


  • 0

    It takes the character from user


  • 0

    Its a function to move editor to output window


Did Not Get The Answer? 
Contact people of Talent-C Language directly from here

C Language