欢迎光临
我们一直在努力

isspace()当str字符串中包含空格

isspace() checks for white-space characters. In the “C” and “POSIX” locales, these are: space, form-feed (‘\f’), newline (‘\n’), carriage return (‘\r’), horizontal tab (‘\t’), and vertical tab (‘\v’).

函数int isspace ( int c );

用便宜美国vps于判断字符c是否是空字符,是空字符返回值为非0,不是空字符返回值为0

例子判断字符串字符是否为空,是空字符,则将空字符替换成’#’

#include<stdio.h>#include<ctype.h>int main(){char c;int i=0;char str[]=”isspace test one”;while(str[i]){c=str[i];if(isspace(c))c=’#’;putchar(c);i++;}return 0;}

运行结果:

zdg@ubuntu:/mnt/hgfs/SHAREZDG/C_PROJECT$ ./a.out isspace#test#onezdg@ubuntu:/mnt/hgfs/SHAREZDG/C_PROJECT$

?

64467167

赞(0)
【声明】:本博客不参与任何交易,也非中介,仅记录个人感兴趣的主机测评结果和优惠活动,内容均不作直接、间接、法定、约定的保证。访问本博客请务必遵守有关互联网的相关法律、规定与规则。一旦您访问本博客,即表示您已经知晓并接受了此声明通告。