S
Starman
This is something I've pondered on for some years. The pointer symbol
* is tied to the variable, not to the type. So in all the code I've
seen so far I found:
char *pc;
however I would (and I tend to) write:
char* pc;
I know the second is not syntactically correct because
char *pc1, *pc2; // works
char* pc1, pc2; // does not work.
But I find the second syntax much more natural and easier to read
through.
This syntax has always given me problems in particular when
deciphering other people's code, especially when it comes to pointers
to pointers like often found in function parameters.
Since the * symbol is also used for dereferencing a pointer, I often
get confused and I have to stop and think the code through (and lose
quite a bit of time).
I was wondering if others think it the same way.
* is tied to the variable, not to the type. So in all the code I've
seen so far I found:
char *pc;
however I would (and I tend to) write:
char* pc;
I know the second is not syntactically correct because
char *pc1, *pc2; // works
char* pc1, pc2; // does not work.
But I find the second syntax much more natural and easier to read
through.
This syntax has always given me problems in particular when
deciphering other people's code, especially when it comes to pointers
to pointers like often found in function parameters.
Since the * symbol is also used for dereferencing a pointer, I often
get confused and I have to stop and think the code through (and lose
quite a bit of time).
I was wondering if others think it the same way.