The isprint()
function checks whether or not the character passed to it is a printable character.
#include<ctype.h>
Below is the declaration of isprint()
in C, where c
is the character to be checked:
int isprint(int c);
The function returns an integer value.
If the integer returned is non-zero (true), it means c
is a printable character.
If the integer returned is zero (false), it means c
is not a printable character.
#include <stdio.h>#include <ctype.h>int main(){int count = 0; // store the count of printable charactersint i = 0;while (i < 256) //0 to 255 ASCII characters{if(isprint(i) != 0)// if character is printable,// print it and increase count by 1{printf("%c ", i);++count;}++i;}//print the countprintf("\nThere are %d printable characters in C.\n", count);return 0;}
Free Resources