malloc error: a value of type "void *" cannot be used to initialize an entity of type "int **"

Viewed 12452

I have tried:

int** thread_args = malloc(24);

and

int** thread_args = malloc(sizeof(int*) * 3);

but I keep getting the error message.

I would really appreciate your help!

1 Answers

If you use C++ compiler, you may need to cast the result of malloc:

int ** th_args = (int**)malloc(24)

or simply use operator new.

If you use a C compiler, then... I am not sure of why this error is thrown

Related