0
#include <stdlib.h>
int funcao(int **piParametro)
{
printf("%p\n",&piParametro);
printf("%p\n",piParametro);
printf("%p\n",*piParametro);
printf("%d\n",**piParametro);
return 0;
}
int main()
{
int *piVariavel;
*piVariavel = (int*) malloc(sizeof(int));
*piVariavel = 20;
printf("%p\n",&piVariavel);
printf("%p\n",piVariavel);
printf("%d\n",*piVariavel);
funcao( &piVariavel );
return 0;
}
here is the problem: *piVariable = (int*) malloc(sizeof(int));
– anon
which should be "piVariable = (int*) malloc(sizeof(int));"
– anon
I’ll explain: *piVariable, is to access the memory point to which the pointer points, as you did not allocate anything, before accessing, this pointer ta with an invalid value, and instead of you assign the pointer malloc to it, you were trying to assign to the point to which he pointed
– anon