code as void

some code from the void

Searching the void for “code void”, top hit, Stack Overflow:

What does void mean in C, C++, and C#

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 void in a function argument is optional in C++, so int myFunc() is exactly the same as int myFunc(void), and it is left out completely in C#. It is always required for a return value.

answered 25 Jun 2009 at 10:21
Gerald

edited 15 Oct 2014 at 15:11
Cory Nelson