zl程序教程

您现在的位置是:首页 >  后端

当前栏目

C语言isspace()函数:判断一个字符是否是空白符

C语言字符 函数 一个 判断 是否是
2023-06-13 09:11:59 时间

参数 c 表示要检测的字符。

返回值:返回值为非 0(真)表示c是空白符,返回值为 0(假)表示c不是空白符。

【实例】使用C语言 isspace() 函数检测字符串中是否存在空白字符,如果存在,请替换为换行符。


#include stdio.h 

#include ctype.h 

int main()

 char c;

 int i = 0;

 char str[] = Linux C++/tPython Shell/nC# Java/n 

 while (str[i])

 c = str[i];

 if (isspace(c)) c = /n 

 putchar(c);

 i++;

 return 0;

}

运行结果:
Linux
C++
Python
Shell
C#

22498.html

cC语言javalinuxpython