Correct way of declaring pointer variables in C/C++

Viewed 72513

I noticed some people use the following notation for declaring pointer variables.

(a) char* p;

instead of

(b) char *p;

I use (b). What is the rational behind the notation (a)? Notation (b) makes more sense to me because character pointer is not a type itself. Instead the type is character and the variable may be a pointer to the character.

char* c;

This looks like there is a type char* and the variable c is of that type. But in fact the type is char and *c (the memory location pointed by c) is of that type (char). If you declare multiple variables at once this distinction becomes obvious.

char* c, *d;

This looks weird. Both c and d are same kind of pointers that point to a character. In this since the next one looks more natural.

char *c, *d;
5 Answers
Related