[Solved] Unable to malloc char** [closed]


words = malloc(MAX_WORDS * sizeof(char*));

Should read

words = (char**)malloc(MAX_WORDS * sizeof(char*));

Your compiler is mad because you are attempting to assign a void pointed to a char pointer, so you need to typecast it to char** to work properly.

EDIT: Apparently this is because I am using a C++ compiler. In C you should not be casting the result of malloc(). If you are using C++ you should switch to new and delete if possible.

11

solved Unable to malloc char** [closed]