strtolower?
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
Damn, just write a function. I don't understand this affection for large macros. They're hardly readable and they increase the size of the compiled code because it is copied to every location is is being used rather than being referenced from a single location.

To understand what is happening, refer to a character table, like this one: http://www.asciitable.com/
You will notice that capital letters and lowercase letters are exactly 32 characters apart from each other. Thus, to convert an uppercase letter to a lowercase one, one must only add 32. Conversely, to convert a lowercase letters to an uppercase one, subtract 32. This is what the (1 << 5) boils down to, only in less readable way.

The pipe symbol means bitwise OR, which combines all the set bits in one number with all set bits in another number to form a number that has all bits turned on that are in either number. But in this case a regular addition (+=) might as well have been used.

And then we see that this macro has a huge flaw: it doesn't check for any other characters or punctuation. So if any of those are present they will be garbled up.
Thanks! You've cleared some questions I had.

Thanks everybody
Reply


Messages In This Thread
strtolower? - by Kemula - 30.05.2016, 19:35
Re: strtolower? - by AndreT - 30.05.2016, 19:39
Re: strtolower? - by zSuYaNw - 30.05.2016, 19:49
Respuesta: Re: strtolower? - by Kemula - 30.05.2016, 21:01
Re: strtolower? - by Vince - 30.05.2016, 22:06
Re: strtolower? - by SickAttack - 31.05.2016, 01:29
Re: strtolower? - by SyS - 31.05.2016, 02:51
Re: strtolower? - by SickAttack - 31.05.2016, 03:07
Re: strtolower? - by justice96 - 31.05.2016, 03:10
Respuesta: Re: strtolower? - by Kemula - 31.05.2016, 08:02

Forum Jump:


Users browsing this thread: 1 Guest(s)