-
Void
Hi ppl.
I've been lookin through the tuts on this website and have come accross the statement "void" alot.
Can somebody please tell me what is this statement, if it is one and what use is it to me, and if it is any use, how would i use it?
Thank you in advance...
-
it means something like "empty":
Code:
void myFunction(void) // function doesn't return something and it doesn't accept any arguments
{
}
function call: myFunction();
Code:
int myFunction(int value) // function returns something and accepts an integer.
{
return (value+2); // by example
}
function call: int x = myFunction(3); // by example
-
-
void alone is the same as writing no arguments at all. function(void) means that function doesn't take any arguments. If you write void* it means a pointer, rather than writing int* which means a pointer to an int, or char* which means a pointer to a char. void* is just a pointer, not to any specific type. If you are going to have a function that doesn't return anything you must use void function.
-
kk, thanks for all of your help