Okay, I'm having trouble here with the "owner" of the asterisk - that is, what symbol it applies to...
Here's why I'm confused.
If you declare a char*, say: char* a; - I find that way more intuitive because you're NOT declaring a char type, it's a pointer, therefore I would believe that the asterisk should side with the type of pointer that it is, not with the variable...the only reason you even need to specify the type of the pointer is for arithmetic and some loose type checking...if you're not doing arithmetic on the pointer, you can use void pointers for everything...so why does it belong to the variable?
But we know this isn't true, it belongs to the variable, which is why when you declare multiples, you have to specify each one, ie. char *a, *b; This rationale makes no sense to me, as I feel it should apply to the type, not the variable. It's only allocating 4 (generally, anyway) bytes on the stack for the pointer, not the sizeof the type.
But whatever, I don't get that, but ok.
But then when you typedef, something, ie.
It is suddenly not only an attribute of the type, but now it's BEFORE the type, where it was originally after...I would expect something more along the lines of:Code:typedef char CHAR, *PCHAR;
But no.Code:typedef char CHAR, PCHAR*;
Then there's prototypes - just the prototype - in C, no variable name is required, so your prototypes can look like this:
Again, eluding to the concept that the asterisk (the property) applies to the type, not the variable.Code:functionA(char*, int*);
Can somebody explain this MESS to me? I just see so much inconsistency, and I never really cared about it, but now it's starting to bother me for some reason :-\.
And plz don't tell me to search, all the searching I've done has only told me that the asterisk applies to the variable, not the type - which I know, but that's not answering my question.