In fact, how would the compiler interpret these two statements? int *a, b; int * c, d; I'm pretty sure a is a pointer to int, b is an int, c is a pointer, but=20 not quite sure about d. How about a struct typedef ? typedef struct tag_fooT { int foo; char *s; } fooT, *pfooT; I know that declaring a fooT allocates space for the structure, and=20 declaring a pfooT allocates just the pointer as I do this all the time. fooT fooStructA; pfooT fooPointer =3D &fooStructA; Joe W On 9/29/2012 12:49 PM, Tamas Rudnai wrote: > I prefer B, that is the most common -- plus as you have pointed out, with > the 'int' you only told the compiler the base type, but with the '*' you > are telling that this particular variable is a pointer type to that base > type. So even if syntax allows you to do the way A, semantically it is > still the way B. > > Tamas > > > On 29 September 2012 09:17, V G wrote: > >> This is an opinion question. I am curious as to what you all think is a >> good way to do this: >> >> In C/C++, what is your preferred way or declaring pointers? >> >> A) int* p; >> B) int *p; >> C) int * p; >> >> I think it should be A because it's logical and the C/C++ compiler >> considersint*to be the type, and the syntax is ; >> >> However, I see B a lot in code, and it doesn't make sense to me. Also, >> function prototypes are usually written like so: >> >> void myFunction(int*, int*, char*); with the asterisk close to the type. >> >> Note that when doing this: >> >> int* x, y; >> >> Type type of x is int* whereas the type of y is int. To make the type of >> both of them int*, one must do: >> >> int *x, *y; >> >> Apparently, the spaces get removed during compile time and it just becom= es >> int*x to the compiler. >> * >> Which way do you prefer?* >> -- >> http://www.piclist.com PIC/SX FAQ & list archive >> View/change your membership options at >> http://mailman.mit.edu/mailman/listinfo/piclist >> > > > --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .