isprint() - Character Function

How to check printable characters in C++?

Explanation

isprint() function is used to check for printable characters including the space but not the control symbols. It returns a zero value if it is not this type.

Syntax:


int isprint ( int c );

Example :



#include <stdio.h>
#include <ctype.h>
#include <conio.h>
int main ()
{
int i=0;
char arr[]="Hiox\tHscripts....";
while (arr[i])
{
if (isprint(arr[i]))
putchar(arr[i]);
else
putchar(arr[i]);
i++;
}
getch();
return 0;
}

Result :

Hiox Hscripts....

In the above example, this function is used to skip loop and print the rest of the printable characters from the array. It checks them based on ASCII values.

C++ Tutorial


Ask Questions

Ask Question