+ 2

Why void does not return any function

16th Nov 2016, 12:16 PM
Samhita Joshi
Samhita Joshi - avatar
3 Respostas
+ 3
That's the whole point of void, it doesn't return anything (unlike int or double).
16th Nov 2016, 12:31 PM
Keto Z
Keto Z - avatar
+ 3
When C was invented the convention was that, if you didn't specify the return type, the compiler automatically inferred that you wanted to return an int (and the same holds for parameters). But often you write functions that do stuff and don't need to return anything (think e.g. about a function that just prints something on the screen); for this reason, it was decided that, to specify that you don't want to return anything at all, you have to use the void keyword as "return type".
16th Nov 2016, 4:18 PM
Vishal Koshti
Vishal Koshti - avatar
+ 1
the meaning of void itself says 'nothing'. it was designed to use where you don't need to return anything
16th Nov 2016, 1:02 PM
P Sandesh Baliga
P Sandesh Baliga - avatar