getchar function in C Programming

getchar function

getchar function will accept a character from the console or from a file, displays immediately while typing and we need to press Enter key for proceeding.

Syntax of getchar() is

         int getchar(void);
		 

It returns the unsigned char that they read.If end-of-file or an error is encountered getchar() functions return EOF.

For example:

        char a;
        a= getchar();
		

The function "getchar()" reads a single character from the standard input device, the keyboard being assumed because that is the standard input device, and assigns it to the variable "a".

The following program illustrates the use of getchar function.

Ready to get started?

Ready to embark on your journey into the world of C programming? Our comprehensive course provides the perfect starting point for learners of all levels. With engaging lessons, hands-on exercises, and expert guidance, you'll gain the skills and confidence needed to excel in this fundamental programming language. Let's dive in and unlock the endless possibilities of C programming together!