Latest web development tutorials

C library functions - iscntrl ()

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

description

Whether the C library functionvoid iscntrl (int c) Check preaching character is a control character.

According to the standard ASCII character set, control characters of ASCII code between 0x00 (NUL) and 0x1f (US), and 0x7f (DEL), certain platform-specific compiler implementations can also be extended character set (0x7f above) in define additional control characters.

statement

The following is a statement iscntrl () function.

int iscntrl(int c);

parameter

  • c - This was a test of character.

return value

If c is a control character, the function returns a nonzero value, otherwise return 0.

Examples

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

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

int main ()
{
   int i = 0, j = 0;
   char str1[] = "all \a about \t programming";
   char str2[] = "w3cschool \n tutorials";
  
   /* 输出字符串直到控制字符 \a */
   while( !iscntrl(str1[i]) ) 
   {
      putchar(str1[i]);
      i++;
   }
  
   /* 输出字符串直到控制字符 \n */
   while( !iscntrl(str2[j]) ) 
   {
      putchar(str2[j]);
      j++;
   }
   
   return(0);
}

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

all w3cschool 

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