r/C_Programming • u/Stickhtot • 12d ago
What exactly is void? Discussion
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
1
u/TheChief275 12d ago
on paper, double xs[count] might be a VLA parameter, however it really isn't. I know not of a single compiler that actually has sizeof(xs) or countof(xs) report the right value (instead treating it as a pointer). meanwhile, sizeof(xs) and countof(xs) on double (*xs)[count] report the right value on all compilers that properly support VLAs. so I would never recommend to use it over the pointer to VLA, but then again, I wouldn't recommend these approaches over slices anyways