C++ 标准库之cctype

本文介绍C++中<cctype>头文件的功能,包括字符测试和字符映射两类操作。文章详细解释了这些函数如何处理ASCII字符,并提供了函数原型及使用限制。

C++ 语言下
头文件:#include <cctype>
说明: 字符处理库
功能一:字符测试
1> 函数原型均为int isxxxx(int)
2> 参数为int, 任何实参均被提升成整型
3> 只能正确处理处于[0, 127]之间的值
 
功能二:字符映射
1> 函数原型为int toxxxx(int)
2> 对参数进行检测, 若符合范围则转换, 否则不变

备注说明:C语言下的此类功能头文件是<ctype.h>
以下是<cctype>头文件的声明:

[cpp]  view plain  copy
  1. // cctype standard header  
  2. #pragma once  
  3. #ifndef _CCTYPE_  
  4. #define _CCTYPE_  
  5. #include <yvals.h>  
  6.   
  7. #ifdef _STD_USING  
  8.  #undef _STD_USING  
  9.   #include <ctype.h>  
  10.  #define _STD_USING  
  11. #else /* _STD_USING */  
  12.  #include <ctype.h>  
  13. #endif /* _STD_USING */  
  14. #ifndef RC_INVOKED  
  15.  #if _GLOBAL_USING  
  16. _STD_BEGIN  
  17. using ::isalnum; using ::isalpha; using ::iscntrl;  
  18. using ::isdigit; using ::isgraph; using ::islower;  
  19. using ::isprint; using ::ispunct; using ::isspace;  
  20. using ::isupper; using ::isxdigit; using ::tolower;  
  21. using ::toupper;  
  22.   
  23. _STD_END  
  24.  #endif /* _GLOBAL_USING */  
  25. #endif /* RC_INVOKED */  
  26.     /* remove any (improper) macro overrides */  
  27. #undef isalnum  
  28. #undef isalpha  
  29. #undef isblank  
  30. #undef iscntrl  
  31. #undef isdigit  
  32. #undef isgraph  
  33. #undef islower  
  34. #undef isprint  
  35. #undef ispunct  
  36. #undef isspace  
  37. #undef isupper  
  38. #undef isxdigit  
  39. #undef tolower  
  40. #undef toupper  
  41. #endif /* _CCTYPE_ */  
  42. /* 
  43.  * Copyright (c) 1992-2006 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  44.  * Consult your license regarding permissions and restrictions. 
  45.  V5.02:0009 */  

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值