In C, return type of getchar(), fgetc() and getc() is int (not char). So it is recommended to assign the returned values of these functions to an integer type variable.
Here is a version that uses integer to compare the value of getchar().
See this for more details.
- Operators in C | Set 1 (Arithmetic Operators)
- Difference between getc(), getchar(), getch() and getche()
- What is the difference between printf, sprintf and fprintf?
- Enumeration (or enum) in C
- Bitwise Operators in C/C++
- To find sum of two numbers without using any operator
- Sequence Points in C | Set 1
- Scansets in C
- puts() vs printf() for printing a string
- What is use of %n in printf() ?
- gets() is risky to use!
- How does "void *" differ in C and C++?
- calloc() versus malloc()
- Return values of printf() and scanf() in C/C++
- How to print % using printf()?