6 ms·
Yes, it is unintuitive. However, there's a reason people do it the unintuitive way, and that's due to the C spec. float* foo, bar; This code declares bar as
by modeless 15y ago
Yes, it is unintuitive. However, there's a reason people do it the unintuitive way, and that's due to the C spec.
float* foo, bar;
This code declares bar as a float, not a pointer! To make things less misleading, most C programmers have adopted the convention of putting the star next to the variable name instead of the type:
float *foo, bar;
even though it looks weird.
- pixie_ 15y agoYea I am aware of this quirk and just avoid declaring multiple pointers like that because it's confusing just to look at, plus error prone.