C Language: isprint function
(Test for Printing Character)
In the C Programming Language, the isprint function tests whether c is a printing character and it does include a space. If you do not wish to include a space, try using the isgraph function.
Syntax
The syntax for the isprint function in the C Language is:
int isprint(int c);
Parameters or Arguments
- c
- The value to test whether it is a printing character and it does include a space.
Returns
The isprint function returns a nonzero value if c is a printing character and returns zero if c is not a printing character.
Required Header
In the C Language, the required header for the isprint function is:
#include <ctype.h>
Applies To
In the C Language, the isprint function can be used in the following versions:
- ANSI/ISO 9899-1990
isprint Example
/* Example using isprint by TechOnTheNet.com */ #include <stdio.h> #include <ctype.h> int main(int argc, const char * argv[]) { /* Define a temporary variable */ unsigned char test; /* Assign a test printable letter to the variable */ test = 'T'; /* Test to see if this character is a printing character */ if (isprint(test) != 0) printf("%c is a printing character\n", test); else printf("%c is not a printing character\n", test); /* Assign a non-printing character to the variable */ test = 0; /* This is NUL */ /* Test to see if this character is a printing character */ if (isprint(test) != 0) printf("NUL is a printing character\n"); else printf("NUL is not a printing character\n"); return 0; }
When compiled and run, this application will output:
T is a printing character NUL is not a printing character
Similar Functions
Other C functions that are similar to the isprint function:
Advertisements