getchar() returns an int

This tip submitted by Rob on 2004-12-29 00:00:00. It has been viewed 30505 times.
Rating of 5.7 with 252 votes

The function getchar() is perhaps named in such a way as to be misleading to novice programmers. It does get a character, but it returns an int. Always assign the return value of getchar() to an int type variable. Read a little more about getchar() here.

More tips

Help your fellow programmers! Add a tip!