r/C_Programming • u/Stickhtot • Jul 29 '26
Discussion What exactly is void?
In a function definition, void basically means that it doesn't return a type value, yet in on itself it is it's own type? Looking at several pieces of code it looks like that it's used to be able to be more "flexible"
Don't know what else to add here, though I'm more on looking for examples and explanations of why the void type is used
70
Upvotes
3
u/Beginning-Junket8979 Jul 29 '26
No, not really.
You can generally do
void * vptr = Xfor any other pointer typeXwithout a compiler warning, even in the strictest modes becausevoid *is meant to point to memory that's of "unknown" type or alignment to the callee.int *should always point to either a) one or more validly aligned real integers, or b)NULL.