void alloco(int *ppa)
{
int i;
printf("inside alloco %d\n",ppa);
ppa = (int *)malloc(20);
ppa[15] = 9;
printf("size of a %d \n", sizeof(ppa));
for(i=0;i<20;i++)
printf("a[%d] = %d \n", i, ppa[i]);
}
int main()
{
int *app = NULL;
int i;
printf("inside main\n");
alloco(app);
for(i=0;i<20;i++)
printf("app[%d] = %d \n", i, app[i]);
return(0);
}
Basically all I wanted to do is to pass a null pointer from my main
to a function(alloco
) which allocates memory/fills the same location the pointer is pointing to and returns. I am getting local prints correctly that is inside function(alloco
) but not in main
.
Am I doing anything wrong here?