Originally Posted by
max1989
i want to know why dont we prefix the pointer with * when using it on dynamic array.
Code:
printf("*normalpointer = %d (prefix the pointer with * here)\n", *normalpointer);
Here you are "dereferencing" the pointer to get to the value it points to. *normalpointer in this case returns an integer.
Code:
int *ptr; //dynamic array pointer
...
printf("%d ",ptr[i]); // *ptr[i] is illegal why ??
}
In this case the pointer is dereferenced by the [] brackets. ptr[i] is the same as *(ptr+i) ... go ahead try it...