isspace
描述 (Description)
它检查字符是否为空格,其他语言环境可能会将不同的字符选择视为空格,但从不为isalnum返回true的字符。
声明 (Declaration)
以下是std :: isspace的声明。
C++98
int isspace ( int c );
C++11
int isspace ( int c );
参数 (Parameters)
c - 要检查的字符,转换为int或EOF。
返回值 (Return Value)
它返回一个不等于零的值。
异常 (Exceptions)
No-throw guarantee - 此函数永远不会抛出异常。
例子 (Example)
在下面的示例中为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