Re: casting to unsigned char for is*() and to*() functions
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Thu, 30 Jun 2005 03:19:18 GMT
Eric Sosman wrote:
>
.... snip ...
>
> If `c' is an `int' obtained from something like getc(),
> just pass it along without casting. getc() and its ilk
> already return either EOF or a non-negative `unsigned char'
> value, which is what toupper() et al. require.
I think the point is that getc and friends do not return a char,
they all return an int. So unless the OP makes the beginners
mistake of storing that value in a char, all is correct without any
special effort. Thus the prototype for filling a char array is:
while (EOF != (ch = getc(...))) {
/* make tests on ch */
/* optionally store ch in a char array */
}
and the tests on the intermediate storage ch needs no special care,
provided that is of type int.
--
"A man who is right every time is not likely to do very much."
-- Francis Crick, co-discover of DNA
"There is nothing more amazing than stupidity in action."
-- Thomas Matthews
.
- References:
- casting to unsigned char for is*() and to*() functions
- From: mr_semantics
- Re: casting to unsigned char for is*() and to*() functions
- From: Eric Sosman
- casting to unsigned char for is*() and to*() functions
- Prev by Date: Re: Floatin point issues
- Next by Date: Re: Floatin point issues
- Previous by thread: Re: casting to unsigned char for is*() and to*() functions
- Next by thread: Re: casting to unsigned char for is*() and to*() functions
- Index(es):
Relevant Pages
|