C++ getchar() Function Last Updated : 27 Nov, 2022 Comments Improve Suggest changes Like Article Like Report getchar( ) is a function that takes a single input character from standard input. The major difference between getchar( ) and getc( ) is that getc( ) can take input from any number of input streams but getchar( ) can take input from a single standard input stream. It is present inside the stdin.h C library. Just like getchar, there is also a function called putchar( ) that prints only one character to the standard output screen Syntax: int getchar(void); Return Type: The input from the standard input is read as an unsigned char and then it is typecasted and returned as an integer value(int) or EOF(End Of File). A EOF is returned in two cases, 1. when file end is reached. 2. When there is an error during execution. Example: C++ // C++ Program to implement // Use of getchar() #include <cstdio> #include <iostream> using namespace std; int main() { char x; x = getchar(); cout << "The entered character is : " << x; return 0; } Output: Output Example : C++ // C++ Program to implement // Use of getchar() and putchar() #include <cstdio> #include <iostream> using namespace std; int main() { char x; x = getchar(); cout << "The entered character is : "; putchar(x); return 0; } Output: Output Comment More infoAdvertise with us Next Article C++ getchar() Function S sayanc170 Follow Improve Article Tags : Technical Scripter C++ Technical Scripter 2022 CPP-Library Practice Tags : CPP Similar Reads getchar Function in C C getchar is a standard library function that takes a single input character from standard input. The major difference between getchar and getc is that getc can take input from any no of input streams but getchar can take input from a single standard input stream. It is defined inside the <stdio. 3 min read putwchar() function in C/C++ The putwchar() function in C/C++ writes a wide character to stdout (standard output). It is defined in CPP library . Syntax : wint_t putwchar(wchar_t ch) Parameter : The function accepts one mandatory parameter ch which specifies the wide character to be written. Return value : The function returns 2 min read wmemchr() function in C/C++ The wmemchr() function in C/C++ Locate character in block of wide characters. This function searches within the first num wide characters of the block pointed by ptr for the first occurrence of ch, and returns a pointer to it. Syntax: const wchar_t* wmemchr( const wchar_t* ptr, wchar_t ch, size_t nu 3 min read C String Functions C language provides various built-in functions that can be used for various operations and manipulations on strings. These string functions make it easier to perform tasks such as string copy, concatenation, comparison, length, etc. The <string.h> header file contains these string functions.Th 6 min read C++ printf() Function printf() function is originally declared under the <cstdio>header file. It prints the formatted string to the standard output stdout. Syntax: int printf(const char*word, .......) Parameters: word: represents the string that needs to be printed on the standard output stdout,....... : represents 3 min read Like