Latest web development tutorials

C library functions - isspace ()

C standard library - <ctype.h> C standard library - <ctype.h>

description

Whether the C library functionint isspace (int c) Check preaching character is a blank character.

Standard blank characters include:

' '     (0x20)	space (SPC) 空格符
'\t'	(0x09)	horizontal tab (TAB) 水平制表符	
'\n'	(0x0a)	newline (LF) 换行符
'\v'	(0x0b)	vertical tab (VT) 垂直制表符
'\f'	(0x0c)	feed (FF) 换页符
'\r'	(0x0d)	carriage return (CR) 回车符

statement

The following is a statement isspace () function.

int isspace(int c);

parameter

  • c - This was a test of character.

return value

If c is a blank character, the function returns a nonzero value (true), otherwise it returns 0 (false).

Examples

The following example demonstrates the use of isspace () function.

#include <stdio.h>
#include <ctype.h>

int main()
{
   int var1 = 't';
   int var2 = '1';
   int var3 = ' ';

   if( isspace(var1) )
   {
       printf("var1 = |%c| 是空白字符\n", var1 );
   }
   else
   {
       printf("var1 = |%c| 不是空白字符\n", var1 );
   }
   if( isspace(var2) )
   {
       printf("var2 = |%c| 是空白字符\n", var2 );
   }
   else
   {
       printf("var2 = |%c| 不是空白字符\n", var2 );
   }
   if( isspace(var3) )
   {
       printf("var3 = |%c| 是空白字符\n", var3 );
   }
   else
   {
       printf("var3 = |%c| 不是空白字符\n", var3 );
   }
   
   return(0);
}

Let's compile and run the above program, which will result in the following:

var1 = |t| 不是空白字符
var2 = |1| 不是空白字符
var3 = | | 是空白字符

C standard library - <ctype.h> C standard library - <ctype.h>