Re: tolower() and toupper()



Simon Biber wrote:
CBFalconer wrote:
"*** T. Winter" wrote:
"Roman Mashak" <mrv@xxxxxxxx> writes:
what's the point to declare argument to these functions of 'int'
type, not char?
That is to make the following work:
int c1, c2;
while((c1 = getchar()) != EOF) {
c2 = tolower(c1);
}

Which, assuming you need both the values of c1 and c2 preserved, is
more simply written as:

while (EOF != (c2 = tolower(c1 = getchar))) continue;

since the tolower call will preserve the value EOF.

I think you meant to call getchar, rather than trying to assign a
function pointer to c1. A set of parentheses is missing.

Thanks for catching that. Should be:
while (EOF != (c2 = tolower(c1 = getchar()))) continue;

--
Chuck F (cbfalconer at maineline dot net)
Available for consulting/temporary embedded and systems.
<http://cbfalconer.home.att.net>


.