isprint Function

Test for a printable character (includes a space).

Include

<ctype.h>

Prototype

int isprint (int c);

Argument

c
The character to test.

Return Value

Returns a non-zero integer value if the character, c, is printable; otherwise, returns zero.

Remarks

A character is considered to be a printable character if it is in the range 0x20 to 0x7e inclusive.

Example

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

int main(void)
{
  int ch;

  ch = '&';
  if (isprint(ch))
    printf("& is a printable character\n");
  else
    printf("& is NOT a printable character\n");

  ch = '\t';
  if (isprint(ch))
    printf("a tab is a printable character\n");
  else
    printf("a tab is NOT a printable character\n");
}

Example Output

& is a printable character
a tab is NOT a printable character