getchar() returns an int

This tip submitted by Rob on 2004-12-29 00:00:00. It has been viewed 23812 times.
Rating of 6.2 with 194 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!