• C programming language provides a rich set of Input-Output (I/O) functions to make the I/O operations easily. They are available inside stdio.h header file so we need to include stdio.h into our program to use them.
  • In this post, we will look into some of the most common I/O functions in detail.

1. getchar()

Use:

It is used to read one character from the standard input device. It is available in <stdio.h>  header file.

Syntax:

var = getchar () ;

Example

char ch = getchar() ;
printf(“\n You entered %c “, ch);

Output:

You entered S

2. getch()

Use:

It is used to read character from the standard input device. It will not echo the character that you are inputting. Computer waits till you enter character from the input device and assigns it to the character variable. There is no need to press enter key when you finish data input. It is available in <conio.h>  header file.

Syntax:

var = getch () ;

Example

char ch = getch() ;
printf(“\n You entered %c “, ch);

Output:

You entered S

3. putchar()

Use:

It is used to write one character on the terminal. It is available in <stdio.h>  header file.

Syntax:

putchar (char) ;

Example

char ch = 'C' ;
putchar(ch);

Output:

C

Leave a Reply

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