If void() does not return a value, why do we use it?

Viewed 46941

void f() means that f returns nothing. If void returns nothing, then why we use it? What is the main purpose of void?

11 Answers

Functions are not required to return a value. To tell the compiler that a function does not return a value, a return type of void is used.

Related