0

I can't understand what is the difference of void type data type to the other data types, can anyone explain what is the use of void data type to a program

26th Aug 2016, 12:01 AM
Joshua Mariscotes
2 Respuestas
+ 1
Void is used when your function will not return nothing. Return is not the same as output. Declaring not void a function means that you will return something and the compiler reserves some memory to allocate the returning value. C and C++ are efficient languages, the storage of variables cost memory, and there are aplications where the memory is very little. For this reason is interesting the option of declare void functions. For example, Arduino code is based on C.
26th Aug 2016, 12:59 AM
Néstor
Néstor - avatar
+ 1
Void is not a data type. It basically means "empty". It is used to indicate a function won't take any parameter or return anything. void MyFunc(int a) is a function returning nothing. int MyFunc2(void) is a function accepting no parameter. int MyFunc3() is a function accepting as many parameters as you want. Most people writing this actually mean that it doesn't take any parameter and should have written it with void, like in MyFunc2.
26th Aug 2016, 8:17 AM
Zen
Zen - avatar