Single Character Input – getchar ( ) Function:


The getchar ( ) is a part of I/O library functions available in C. It returns a single character from a standard input device. This function does not require any arguments, though a pair of empty brackets must follow the getchar ( ).

 Generally, it is written as


There are two other I/O library functions i.i. getch ( ) and getche ( ).



Program to take a input by getchar ( ) function.
#include<stdio.h>
#include<conio.h>
main()
{
            char ch;
            ch=getchar();
            printf(“character input by user is %c”,ch);
            getch();
}
Output:
A
Character input by user is a


Single Character Output putchar ( ) Function:
The putchar ( ) is also another I/ O library function available in C. It transmits a single character to a standard output device (monitor). The character being transmitted is normally represented as a character type variable. It is normally written as putchar ( ).

Previous                                                                                     Next

Powered by Blogger.