This is my function create
void create(int *array, int size)
{
*array = (int *)malloc(size * sizeof(int));
}
Here I am trying to create dynamic table
Now in int main I am trying to make a pointer for a function create and then call it
int main(void)
{
int *array;
int size = 64;
void (*create_array)(int *, int) = create;
create_array(&array, size);
}
And here is the error that I am getting after F9 and really long compilation time:
In function 'create':
assignment makes integer from pointer without a cast [-Wint-conversion]|
In function 'main':
note: expected 'int *' but argument is of type 'int **'
I was trying to edit this function
void create(int *array, int size)
{
array = (int *)malloc(size * sizeof(int));
}
or
void create(int *array, int size)
{
int *ptr;
*ptr = *array;
*ptr = (int *)malloc(size * sizeof(int));
}
But my program crashes after this