Mega Code Archive

 
Categories / C / Code Snippets
 

Returns nonzero if ch is a printable character

other than space or zero is returned //Declaration: int isgraph(int ch); //Return: returns nonzero if ch is a printable character other than space or zero is returned. #include <ctype.h> #include <stdio.h> int main(void) { char ch; for(;;) { ch = getchar(); if(isgraph(ch)){ printf("%c is printable\n", ch); } if(ch == '.'){ break; } } return 0; } /* 4 4 is printable 8 8 is printable 2 2 is printable 1 1 is printable . . is printable */