As titled.
void foo() {}
int main(void) {
foo(); // what is the value of this expression?
}
Does it mean that void
is also a type of value in C? Or how should I understand that?
As titled.
void foo() {}
int main(void) {
foo(); // what is the value of this expression?
}
Does it mean that void
is also a type of value in C? Or how should I understand that?
A void expression has no value, and in fact cannot be used. This is described in detail in section 6.3.2.2 of the C standard:
The (nonexistent) value of a void expression (an expression that has type
void
) shall not be used in any way, and implicit or explicit conversions (except tovoid
) shall not be applied to such an expression. If an expression of any other type is evaluated as a void expression, its value or designator is discarded. (A void expression is evaluated for its side effects.)