isprint - C ctype.h

C examples for ctype.h:isprint

Type

function

From

<cctype> 
<ctype.h>

Description

Check if character is printable

Prototype

int isprint ( int c );

Parameters

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

Return Value

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

The following code prints a string character by character until a character that is not printable.

Demo Code


#include <stdio.h>
#include <ctype.h>
int main ()//from   w  ww . j av a2s .  c om
{
  int i=0;
  char str[]="first line \n second line \n";
  while (isprint(str[i]))
  {
    putchar (str[i]);
    i++;
  }
  return 0;
}

Related Tutorials