anyway, with this in mind, can someone explain something to me? in C, i tend to write this:
int* x;
i write it like that because i believe i am bringing into existence x, whose type is "a pointer to an integer". it's not an int, it's an int pointer. so i write int*, because that's what type it is. it seems clearer that way. however i often see this:
int *x;
this seems less clear, but some (most?) people obviously think THAT way is the clearer way. if you do, what's your thought process?
@jk I thought it was extremely confusing. The object type is a pointer to an integer, not an integer, so wouldn't it be attached to the type specifier?
Honestly hate "int *p"
@senj @shram86 @jk Right, "int *x" is how the language _actually works_. It may not be how we wished it worked, but that is how it works, so it is clearer to write things that way.
If you designed C now, you might design it so that "int* x" is how it works. But that would be a slightly different language.
@WAHa_06x36 @senj @jk does this mean that when parsed, every C interpreter just transposes the asterisk?
Every compiler I've ever used doesn't care where it goes. I know K&R do it one way, but practice is different....
@WAHa_06x36 @senj @jk I'm still unsure of what you mean by "the asterisk belongs to the variable name".
By that logic you can have a int *x and an int x and C wouldn't care but I'm pretty sure it does?