3 ms·
Because now you've got an int pointer and an int. The star associates with the right, not left. I prefer to use the variant you described though, because it fe
by unsafecast 4y ago
Because now you've got an int pointer and an int. The star associates with the right, not left.
I prefer to use the variant you described though, because it feels more natural to associate the pointer with the type itself. As far as I know, the only pitfall is in the multiple declaration thing so I just don't use it.
IMO, it's also more readable in this case:
int *get_int(void);
int* get_int(void);
The second one more clearly shows that it returns a pointer-to-int.
- thomastjeffery 4y agoMultiple declaration is generally frowned upon, because you declare the variables without immediately setting them to something. If you always set new variables in the same statement you declare them, then you don't use multiple declarations, which means there is no ambiguity putting the * by the type name. So convention wins out for convention's sake. And that's the entire point of convention in the first place: to sidestep the ugly warts of a decades-old language design.