3 ms·
Wait, C programmers now put the star on the left hand side? char* thing; // good char *thing; // bad This ... is awesome. As a C++ "native" I've always found
by RantyDave 2y ago
Wait, C programmers now put the star on the left hand side?
char* thing; // good
char *thing; // bad
This ... is awesome. As a C++ "native" I've always found the "star on the right" thing to be really horribly confusing.
- bloppe 2y agoOfc this has always been an option. In my C heyday I used to put a space on both sides of the star. It makes for a more consistent syntax when you have multi layer pointers with const at various layers. For example: // mutable pointer to mutable data: char * str; // Immutable pointer to immutable data: char const*const str; // Mutable pointer to an immutable pointer to a mutable pointer to immutable data: char const**const* strs;
- int_19h 2y agoGiven that putting it on the right reflects the actual syntax tree of the code, why do you find it "horribly confusing"? I mean, one can reasonably argue that C & C++ declarator syntax is itself horribly confusing because it doesn't read left-to-right. But it is what it is, so why pretend that it's something else?