A structured lesson workspace with readable content, hands-on examples, and a clean path to completion.
A void function call is an expression of type void. You cannot assign it. You cannot pass it as an argument. You cannot use it in an arithmetic expression. But you can use it in contexts that accept void expressions: as a standalone statement, in a comma expression, and as the operand of certain operators. Understanding these contexts prevents compilation errors and clarifies what the language permits.
#include <stdio.h>void log_msg(const char *msg) {printf("[LOG] %s\n", msg);}void cleanup(void) {printf("Cleaning up...\n");}int main(void) {log_msg("Standalone statement");int x = 5;x > 3 ? log_msg("x is big") : log_msg("x is small");int y = (log_msg("comma expr"), 42);printf("y = %d\n", y);for (int i = 0; i < 3; i++) {log_msg("in loop");}if (x == 5) log_msg("conditional call");return 0;}
The ternary operator accepts void expressions in both branches. The comma operator evaluates the void call and discards it, returning the right operand. The for loop body and the if body accept void expressions as statements. What you cannot do: int z = log_msg("bad"); or printf("%d", log_msg("bad")). These require a value, and void provides none.
Void function calls are statements, not values. They fit in statement contexts: standalone, in loops, in conditionals, in comma expressions. They do not fit in value contexts: assignment, function arguments, arithmetic. The compiler enforces this. Next: segmentation faults, the crash that every C programmer meets and few fully understand.
Finish the lesson once you have worked through the material. This awards ★ 20 XP.