hello,
i am trying to store some values in an array dynamically.
doing this as i dont want to over allocate memory to my array. so the code goes as follows::
#include<stdio.h>
#include<stdlib.h>
int *p;
main()
{
int i;
for(i=1;i<6;i++)
{ p= (int *)malloc(sizeof(int));
*p++ = i*i;
}
printf("\n %d %d",*p,*(p+1));
}
but in the output am getting all 0's stored in *p...
can someone help me?