Difference between getc(), getchar(), getch() and getche()

getc()

  • This function gets single character as input and returns an integer value. If this fails, it returns EOF.

Syntax of getc()

[pastacode lang=”c” manual=”int%20getc(FILE%20*stream)%3B” message=”” highlight=”” provider=”manual”/]

getchar()

  • The function getchar() reads the character from the standard input while getc() reads from the input stream.

 Syntax of getchar() 

[pastacode lang=”c” manual=”%C2%A0%20int%20getchar(void)%3B” message=”” highlight=”” provider=”manual”/]

getch()

  • The function getch() is a non-standard function.
  • It is included in “conio.h” header file.
  • Getch() is not a part of standard library.
  • It returns the entered character without even waiting for the enter key.

  Syntax of getch()

[pastacode lang=”c” manual=”int%20getch()%3B” message=”” highlight=”” provider=”manual”/]

getche()

  • Like getch(), the getche() function is also a non-standard function and is included in “conio.h” header file.
  • It reads a single character from the keyboard and returns it immediately without even waiting for enter key.

 Syntax of getche()

[pastacode lang=”c” manual=”int%20getche(void)%3B” message=”” highlight=”” provider=”manual”/]

 

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like