Prev Next
- isgraph( ) function in C language checks whether given character is graphical character or not. Syntax for isgraph( ) function is given below.
int isgraph( int x );
- All printable characters are graphical characters except space ( ‘ ‘ ).
Example program for isgraph() function in C:
- In this program, isgraph( ) function checks whether character is graphical character or not.
- If its a graphical character, it is printed in output. Else, control is coming out of while loop. Output is printed as “fresh” since space (” “) is not a graphical character and it can’t be printed in output.
#include <stdio.h>
int main()
{
char string[50] ="fresh 2 refresh n string";
int i = 0;
while(1)
{
if(isgraph(string[i]))
{
putchar(string[i]);
i++;
}
else break;
}
return 0;
}
Output:
| fresh |
..
Other Int, Char validation functions in C language:
- All “int, char validation functions” used in C language are given below. “ctype.h” header files support all these functions in C language.
- Click on each function name below for detail description and example programs.
| S.no | Function | Description |
| 1 | isalpha() | checks whether character is alphabetic |
| 2 | isdigit() | checks whether character is digit |
| 3 | isalnum() | checks whether character is alphanumeric |
| 4 | isspace() | checks whether character is space |
| 5 | islower() | checks whether character is lower case |
| 6 | isupper() | checks whether character is upper case |
| 7 | isxdigit() | checks whether character is hexadecimal |
| 8 | iscntrl() | checks whether character is a control character |
| 9 | isprint() | checks whether character is a printable character |
| 10 | ispunct() | checks whether character is a punctuation |
| 11 | isgraph() | checks whether character is a graphical character |
| 12 | tolower() | checks whether character is alphabetic & converts to lower case |
| 13 | toupper() | checks whether character is alphabetic & converts to upper case |
Prev Next
.