Scene:
1. The functions in the ctype.h in the standard library are used for 1-byte judgments, but the parameters are int, which can easily lead to misuse.
Isalphaiscntrlisdigitisgraphisprintispunctisspaceisxdigit Isalnumislowerisupper
int isspace (int ch);
The most disgusting is the VC + + implementation will be more than 1 bytes of value will directly crash, GCC will not!!!
#if defined (_DEBUG) extern "C" int __cdecl _chvalidator ( int C, int mask ) { _asserte ((unsigned) (C + 1) &l t;=); Return _chvalidator_l (NULL, C, mask);}
So: When using these functions, remember to convert to unsigned char first
Isspace ((unsigned char) s);
What is the wrong use of isspace? One of the things I've come across is using isspace to judge wchar_t bytes, and if more than 255 crashes, you need to cast before using it.
Here the isspace can actually not be implemented by themselves, strong to (unsigned char) on the line, because we use the x86 architecture are low-byte order.
http://blog.csdn.net/infoworld/article/details/41981639
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
[What to note when using the ISXXX function in CType in the standard library]_[primary]_[]