C void Keyword
Example
Create a function that does not return a value:
void myFunction() {
printf("I just got executed!");
}
int main() {
myFunction();
return 0;
}
Definition and Usage
The void keyword means "no type". It has two main uses.
In front of a function name, void means that the function does not return a value. The function does its job, like printing text, but it gives no value back.
With a pointer, like void* ptr, it creates a pointer that can point to data of any type. For example, the malloc() function returns a void pointer.
Related Pages
Read more about functions in our C Functions Tutorial.
Read more about malloc() in our C Allocate Memory Tutorial.