I know this is a stupid question but it there any difference between:
type* identifer;
and
type * identifer;
and
type *identifer;
or is it just whitespace?
I know this is a stupid question but it there any difference between:
type* identifer;
and
type * identifer;
and
type *identifer;
or is it just whitespace?
Just whitespace.
[edit]But someone will come along and also note this:
http://c-faq.com/decl/charstarws.html, which also links to
http://www.research.att.com/~bs/bs_faq2.html#whitespace
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
I like keeping the pointer next to the type just because it's a pointer to a type.
Thanks, I've been looking through some code (quite large examples) and it was scattered about both ways.
I guessed it was because different people coded different parts but I was just checking thank you.
putting * near the type confuses readers.
eg:[code]
int* ptr, normalvaraible; //here only ptr is a pointer if I'm correct...
int *ptr, normalvaraible; // here it is clearer ???
Yes, I agree with you. Supporting for the first style seems not very persuadable (just my opinion).Originally Posted by arjunajay
I tend to put spaces on both sides of the "*".
But it really is all about personal preference.
true, when you are coding for yourself, personal preference is all that matters.Originally Posted by Ari.Patrick
false, when you are part of a development team, then you have to follow the coding standard adopted by that team, and if they choose int *ptr then you have to code it int *ptr, not as int* ptr or int * ptr.
and Dave,
there isn't actually any such thing as a stupid question. there are questions that are asked in a stupid way, but your question doesn't fall into that grouping either.
Originally Posted by Jeff Henager