i want to know why dont we prefix the pointer with * when using it on dynamic array.
Code:#include "stdafx.h" #include <stdio.h> #include <stdlib.h> void main() { int i; int k=10; int *normalpointer; normalpointer=&k; printf("*normalpointer = %d (prefix the pointer with * here)\n", *normalpointer); int *ptr; //dynamic array pointer ptr=(int *)malloc(sizeof(int)*10); //array size 10 printf("Dynamic array created of size 10\n"); printf("printing content without prefixing the pointer by * \n"); for(i=0;i<10;i++) { ptr[i]=i+1; //no * prefix printf("%d ",ptr[i]); // *ptr[i] is illegal why ?? } }
I dont have any problem in coding but i just need to know whats the theory going on here.



1Likes
LinkBack URL
About LinkBacks



