4 ms·
You couldn't in C actually without making assumptions the language doesn't guarantee. The language specifies that you can't guarantee the alphabet is in order
by sausagefeet 15y ago
You couldn't in C actually without making assumptions the language doesn't guarantee. The language specifies that you can't guarantee the alphabet is in order like that. Ctypes.h provides functions for checking letters though </pedantic>
- icebraining 15y agoLanguage? The alphabet order is related to the encoding, and UTF-8 (which is what they're probably using) certainly does ensure that, since it's backwards compatible with ASCII.
- CountHackulus 15y agoSure, that works for ASCII and UTF-8, but what if I'm on an IBM System Z machine? Then everything's in EBCDIC, and that's just a nightmare.
- ori_b 15y agoThen you read in ASCII or UTF-8, and don't do your I/O in EBCDIC. Also, you run Z/Linux.
- maximilianburke 15y agoThen you write your own optimization for that case -- for most people assuming that 0-9, A-Z, and a-z will work just fine. Chances are slim that you're running on a system using EBCDIC without knowing it.
- beej71 15y agoOr, as was said, use ctypes.h, which is the Right Thing.