Looking to get the fundamentals on where the term “void” comes from, and why it is called void. The intention of the question is to assist someone who has no C experience, and is suddenly looking at a C-based codebase.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Basically it means “nothing” or “no type”
There are 3 basic ways that void is used:
Function argument:
int myFunc(void)— the function takes nothing.
Function return value:
void myFunc(int)— the function returns nothing
Generic data pointer:
void* data— ‘data’ is a pointer to data of unknown type, and cannot be dereferenced
Note: the
voidin a function argument is optional in C++, soint myFunc()is exactly the same asint myFunc(void), and it is left out completely in C#. It is always required for a return value.