Latest web development tutorials

C library functions - isgraph ()

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

description

C library functionsvoid isgraph (int c) Check whether the character preaching a graphical representation.

Characters with a graphical representation of a character in addition to all the whitespace characters (eg '') outside printable.

statement

Here is () statement isgraph function.

int isgraph(int c);

parameter

  • c - This was a test of character.

return value

If c is a graphical representation, the function returns a nonzero value, otherwise return 0.

Examples

The following example demonstrates isgraph () function is used.

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

int main()
{
   int var1 = '3';
   int var2 = 'm';
   int var3 = ' ';
    
   if( isgraph(var1) )
   {
       printf("var1 = |%c| 是可打印的\n", var1 );
   }
   else
   {
      printf("var1 = |%c| 是不可打印的\n", var1 );
   }
   if( isgraph(var2) )
   {
       printf("var2 = |%c| 是可打印的\n", var2 );
   }
   else
   {
      printf("var2 = |%c| 是不可打印的\n", var2 );
   }
   if( isgraph(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 = |3| 是可打印的
var2 = |m| 是可打印的
var3 = | | 是不可打印的

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