-1

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?

Jason Yu
  • 1,886
  • 16
  • 26

1 Answers1

1

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 to void) 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.)

dbush
  • 205,898
  • 23
  • 218
  • 273