Dotcpp  >  编程教程  >  ctype.h头文件  >  C语言isprint()函数:判断字符是否为可打印字符(含空格)

C语言isprint()函数:判断字符是否为可打印字符(含空格)

点击打开在线编译器,边学边练

函数名: isprint

头文件:<ctype.h>

函数原型:  int isprint(int ch);

功 能:  判断字符是否为可打印字符(含空格)

参数: int ch  待检查的字符

返回值: ch不是可打印字符  返回0 , ch是可打印字符(含空格)   返回非0


程序例: 判断输入的字符是否为可打印字符(含空格)

#include<ctype.h>

#include<stdio.h>

int main(){

   char ch;

   printf("input a character:");

   scanf("%c",&ch);

   if(isprint(ch)){

      printf("%c is print character.",ch);

   }else{

      printf("%c is not print character.",ch);

   } 

   putchar('\n');   

   return 0;  

}

运行结果:

input a character:g
g is print character.



本文固定URL:https://www.dotcpp.com/course/440

C语言函数库
assert.h头文件
ctype.h头文件
float.h头文件
io.h头文件
math.h头文件
mem.h头文件
setjmp.h头文件
stdio.h头文件
stdlib.h头文件
sigal.h头文件
string.h头文件
time.h头文件
Dotcpp在线编译      (登录可减少运行等待时间)