Ritchie intentionally designed C's declaration syntax to be "the thing on the right, if it were used in an expression, has the type of the thing on the left." So int *x means *x when used in an expression has the type int — therefore, by implication, x must be a pointer to int.
C is what it is. No amount of ranting will change it. Many before you have ranted about this same thing using the same arguments, so you're not bringing anything new to the table. If you're going to read other people's C code, you just have to get used to it. If if bothers you so much, you're free not to use C at all.
Incidentally, it's trivial to make the counter argument: the * is not part of the type (no matter how badly you might want it to be), so don't make it look like it is.
If that were the case then int * x would be a compiler error. Seems like Ritchie just made a mistake and forgot to point out that int* is a type, so everyone just kept making the same mistake.
No, it wouldn't because whitespace largely insignificant. In your example, the "thing on the right" is still* x. The space doesn't matter.
What's actually more annoying about C is that when you declare something like int f(int a[4]) that it's highly deceptive since C doesn't have array parameters.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Ritchie intentionally designed C's declaration syntax to be "the thing on the right, if it were used in an expression, has the type of the thing on the left." So
int *xmeans*xwhen used in an expression has the typeint— therefore, by implication,xmust be a pointer toint.C is what it is. No amount of ranting will change it. Many before you have ranted about this same thing using the same arguments, so you're not bringing anything new to the table. If you're going to read other people's C code, you just have to get used to it. If if bothers you so much, you're free not to use C at all.
Incidentally, it's trivial to make the counter argument: the
*is not part of the type (no matter how badly you might want it to be), so don't make it look like it is.If that were the case then
int * xwould be a compiler error. Seems like Ritchie just made a mistake and forgot to point out thatint*is a type, so everyone just kept making the same mistake.No, it wouldn't because whitespace largely insignificant. In your example, the "thing on the right" is still
* x. The space doesn't matter.What's actually more annoying about C is that when you declare something like
int f(int a[4])that it's highly deceptive since C doesn't have array parameters.