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
View all comments
Show parent comment
1
u/Beginning-Junket8979 Aug 05 '26
Passing a pointer to a struct into a function that expects a pointer to an int is a bad "code smell" most of the time. If it operates on one int,
&the addr of that specific member. If it operates on the whole struct, use the struct type as your function definition.You "technically can" do a lot of dumb stuff with pointers. It doesn't make it good code.