A structured lesson workspace with readable content, hands-on examples, and a clean path to completion.
isgraph returns nonzero for printable characters excluding the space character. It is isprint minus the space. Letters, digits, and punctuation all pass. Space does not. This is useful when you need to detect visible content: a string that passes isgraph for every character has no whitespace and no control characters. It is a stricter test than isprint and a more inclusive test than isalnum.
#include <stdio.h>#include <ctype.h>int main(void) {const char *tests[] = {"Hello", "Hi there", "abc123!", " ", ""};int n = 5;for (int i = 0; i < n; i++) {int all_graph = 1;int len = 0;for (const char *p = tests[i]; *p; p++) {len++;if (!isgraph((unsigned char)*p)) {all_graph = 0;}}printf("%-12s len=%d all_graph=%d\n",len > 0 ? tests[i] : "(empty)", len, all_graph);}return 0;}
"Hi there" fails because of the space. The three-space string fails for the same reason. "Hello" and "abc123!" pass because every character is a visible glyph. The empty string vacuously passes because there are no characters to fail. This is the correct behavior for a universal quantifier over an empty set, and it is worth remembering when you write validation loops.
isgraph is the strictest printable test. Use it when you need to verify that a string contains only visible glyphs with no whitespace. It is the right check for tokens, identifiers, and compact data fields. Next: time(NULL), the most common way to get the current timestamp, and what the return value actually means.
Finish the lesson once you have worked through the material. This awards ★ 10 XP.