char* p1, p2;

What does 'p2' specify in above statement ? pointer to Character or just a character variable?



Nothing is wrong with the declaration. The * in a pointer declaration is not part of the base type

 type identifier ; 

In the declaration as written in the question, no matter what the whitespace suggests, the base type is char and the first declarator is ``* p1'', and since the declarator contains a *, it declares p1 as a pointer-to-char. The declarator for p2, however, contains nothing but p2, so p2 is declared as a plain char, probably not what was intended. To declare two pointers within the same declaration, use
 char *p1, *p2;

Since the * is part of the declarator, it's best to use whitespace as shown; writing char* invites mistakes and confusion.

Comments