iscntrl - C ctype.h

C examples for ctype.h:iscntrl

Type

function

From

<cctype> 
<ctype.h>

Description

Check if character is a control character

Prototype

int iscntrl ( int c );

Parameters

Parameter Description
c Character to be checked, casted to an int, or EOF.

Return Value

A non zero value (i.e., true) if c is a control character. Zero (i.e., false) otherwise.

The following code prints a string character by character until a control character that breaks the while-loop is encountered.

Demo Code


#include <stdio.h>
#include <ctype.h>
int main ()//from   w ww.  j a  va  2 s  .  c om
{
  int i=0;
  char str[]="this is a test. first line \n second line \n";
  while (!iscntrl(str[i]))
  {
    putchar (str[i]);
    i++;
  }
  return 0;
}

Related Tutorials