JPDev@programming.dev to Programmer Humor@programming.dev · 10 months agoWhitespaceprogramming.devimagemessage-square58fedilinkarrow-up1303arrow-down110
arrow-up1293arrow-down1imageWhitespaceprogramming.devJPDev@programming.dev to Programmer Humor@programming.dev · 10 months agomessage-square58fedilink
minus-squaresweng@programming.devlinkfedilinkarrow-up87arrow-down2·edit-210 months agoYou would think so, but int* a, b is actually eqivalent to int* a; int b, so the asterisk actually does go with the name. Writing int* a, *b is inconsistent, so int *a, *b is the way to go.
minus-squarenewH0pe@feddit.delinkfedilinkarrow-up57arrow-down1·10 months agoYeah, and I’d say that’s a design flaw of the language as it is unintuitive behaviour.
minus-squareSlotos@feddit.nllinkfedilinkarrow-up38·10 months agoWhen people say “pointers are hard”, they mean “I have no idea where the star goes and now an ampersand is also implicated”.
minus-squareT156@lemmy.worldlinkfedilinkEnglisharrow-up24·10 months agoThat’s the part where you give up and randomly shove/unshove symbols in until the code works.
minus-squareCanadaPlus@futurology.todaylinkfedilinkEnglisharrow-up5·10 months agoI’ve definitely never been guilty of this. /s
minus-squareGladaed@feddit.delinkfedilinkarrow-up17arrow-down2·10 months agoDon’t declare more than 1 pointer per line. This resolves that, badly.
minus-squareCanadaPlus@futurology.todaylinkfedilinkEnglisharrow-up8·10 months agoAlright, I’ll never, ever write something this way now. Good to know.
You would think so, but
int* a, b
is actually eqivalent toint* a; int b
, so the asterisk actually does go with the name. Writingint* a, *b
is inconsistent, soint *a, *b
is the way to go.Yeah, and I’d say that’s a design flaw of the language as it is unintuitive behaviour.
When people say “pointers are hard”, they mean “I have no idea where the star goes and now an ampersand is also implicated”.
That’s the part where you give up and randomly shove/unshove symbols in until the code works.
I’ve definitely never been guilty of this. /s
Don’t declare more than 1 pointer per line. This resolves that, badly.
Alright, I’ll never, ever write something this way now. Good to know.
This is true in C, but not in D.