difference between int* p and int *p declarationThis tip submitted by omprakash mishra on 2006-03-13 13:43:38. It has been viewed 27554 times.
Rating of 7.0 with 430 votes
Be careful when declaring a pointer variable to any type--for instance if you are going to declare a pointer to integer with statement
and you decide to declare another pointer to integer, you may declare it like this way :
int* p, q;
since here the * is associated to the int you may think that what ever variable you declare is a pointer variable. But q is actually an ordinary non-pointer variable here.
so be careful! You have to write this as:
int *p, *q;
Or better yet, just use two lines of code:
Help your fellow programmers! Add a tip!