• It means completely null or empty, although it isn't to be confused with the null keyword. In c, it can mean that a function does not return a value. For example, this c++ code doesn't return anything: void printEli() { cout << "Eli"; }
  • void if return with a function means that it does not return any value
  • There are basic five data type. char, int ,double,float and void. means void can store nothing. for example, if you want to create a function that will not return any thing then you can declare with void <fun_name>(arguments) { } if you will not write "void" before function, you have to return something. and by the way, if you ignore it, C compiler will consider that function has prototype INT.
  • The other answers are correct, but they don't mention the other use for void, which is in an opaque pointer. For example, a very common prototype looks like this: void *open_opaque_object(int v, char *str); In this case, a (void *) type is not nothing. It is a pointer which the caller cannot dereference to point to anything usable by him, but is a pointer to memory nonetheless. Typically this value would be used in subsequent call on the opaque object, like this: int reset_opaque_object(void *obj); The idea behind this is to facilitate "data hiding". The user of the API does not know what the pointer points to and so cannot (easily) manipulate data in that object's memory, making it a safer programming style, which means the code should be easier to develop and maintain over time.

Copyright 2020, Wired Ivy, LLC

Answerbag | Terms of Service | Privacy Policy