←back to thread

The C23 edition of Modern C

(gustedt.wordpress.com)
515 points bwidlar | 1 comments | | HN request time: 0.219s | source
Show context
RantyDave ◴[] No.41863140[source]
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.

replies(2): >>41863280 #>>41880136 #
1. bloppe ◴[] No.41863280[source]
Ofc 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;