Name

isprint - character classification routines

Library

libc.lib

Synopsis

  #include <ctype.h>
  int isprint (int c);

Return values

The isprint function returns non-zero if ’c’ is printable and zero otherwise.

Detailed description

The isprint function returns true if ’c’ is a printable character. It considers characters under class space, but characters falling under class cntrl will not be considered(see defns for definition of these classes).

For single character representations, the value of the argument is representable as an unsigned char or the value of EOF.

The functionality of this API is independent of the program’s current locale and so it returns non-zero for all the characters (of various locales supported) that belong to the class print(see defns for definition), irrespective of the locale they belong to.


Examples

#include<ctype.h> //isprint()
#include<stdio.h> //printf()
int test_isprint()
{
   int arr[]={’n’,’\f’, 0xe1, ’6’, ’ ’};
   int i = 0;
   int size = 5;
   for( i=0; i<size; i++)
   {
      int ret = isprint(arr[i]); //call to the API with the chars in arr[]
      if( (!ret) != 0 )
      {
         printf("\n%c is not printable char ", arr[i]);
      }
      else
      {
         printf("\n%c is printable char", arr[i]);
      }
   }
printf("\n");
}

         

Output

n is printable char
  is not printable char
á is not printable char
6 is printable char
  is printable char

         

See also

iswprint

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top