:: Re: [DNG] [OT] [Re: Studying C as t…
Página Principal
Delete this message
Reply to this message
Autor: Irrwahn
Data:  
Para: dng
Assunto: Re: [DNG] [OT] [Re: Studying C as told. (For help)
On Tue, 21 Jun 2016 17:55:52 +0100, Katolaz wrote:
> On Tue, Jun 21, 2016 at 06:41:15PM +0200, Edward Bartolo wrote:
>
> [cut]
>
>>
>> And
>> << if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) >>
>>
>> would reduce to:
>>
>> if (isletter(c))
>>
>
> or, you could just use "isalpha(c)", as suggested also by Urban.


[Piggy-backing]
And it would run much faster (all real-world implementations I
am aware of use some sort of table lookup), and it'd take into
account locale settings.

Lesson: If you find yourself re-implementing a function from the
Standard C Library (except for educational purposes), chances are
you're doing it wrong.

U.