
please wait
|
|
toupper(ch)
returns an integer. Try ... << (char)toupper(ch) << ...
on line 13 instead.
<<
operator interprets types. When it sees toupper(ch)
by itself, it sees an int
, because that's the return type of toupper(ch)
. The behavior for int
is to print a number. Putting (char)
in the front tells it to take the result of toupper(ch)
and interpret the number as a character. The behavior of <<
in regards to char
is to print the letter instead of the ASCII code.