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 become= s > 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 int main() { char *a,*s,*q; printf(s=3D"int main() { char *a,*s,*q; printf(s=3D%s%s%s, q=3D%s%s%s%s,s,q,q,a=3D%s%s%s%s,q,q,q,a,a,q); }", q=3D"\"",s,q,q,a=3D"\\",q,q,q,a,a,q); } --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .