C++ Locale 库 - isspace
描述
它检查字符是否为空格,并且其他语言环境可能会将不同的字符选择视为空格,但绝不会为 isalnum 返回 true 的字符。
声明
以下是 std::isspace 的声明。
C++98
int isspace ( int c );
C++11
int isspace ( int c );
参数
c − 要检查、转换为 int 或 EOF 的字符。
返回值
它返回一个不同于零的值。
异常
No-throw guarantee − 此函数从不抛出异常。
示例
In below example for std::isspace.
#include <stdio.h>
#include <ctype.h>
int main () {
char c;
int i=0;
char str[]="tutorials point india pvt ltd\n";
while (str[i]) {
c=str[i];
if (isspace(c)) c='\n';
putchar (c);
i++;
}
return 0;
}
示例输出应该是这样的 −
tutorials point india pvt ltd

