C++ cctype isgraph() Function
Example
Check if A, # and a space are graphical characters:
cout << (isgraph('A') ? "Yes" : "No") << "\n";
cout << (isgraph('#') ? "Yes" : "No") << "\n";
cout << (isgraph(' ') ? "Yes" : "No");
Definition and Usage
The isgraph() function checks if a character is a graphical character. A graphical character is a character that you can see when it is printed, like a letter, a digit or a punctuation mark.
It returns a non-zero number (true) if it is, and 0 (false) if it is not. The space is not a graphical character, because you cannot see it.
The isgraph function is defined in the <cctype> header file.
Tip: isprint() works the same way, but it also returns true for the space.
Syntax
int isgraph(int c);
Parameter Values
| Parameter | Description |
|---|---|
| c | Required. The character to check. |
Technical Details
| Returns: | An int value. Non-zero (true) if the character is a graphical character, otherwise 0 (false). |
|---|
Related Pages
Read more about strings in our Strings Tutorial.