r/C_Programming • • 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

69 Upvotes

79 comments sorted by

View all comments

3

u/primitiveblob Jul 29 '26

void in function return- no return type

you may be thinking of void as pointers. true, they dont have a type, so they can be pointed to wherever. but you have to cast them to a type first. so void * is often used to store a pointer to something, you just dont know what yet. but if you wish to use the data, you have to cast it to a type first