Hi, when i try to compile my code it comes up with two errors both in the same function.
The errors are both the same:
106assig-4.cpp invalid conversion from `void*' to `int**'
Here is my code:
matrixPointer is an array of arrays using double pointers (or 2D array). rows are the first arrays size and columns is the second. It is an integer array. the module is supposed to assign memory to my array using the pointer.
PLease could some one let me know how I can fix this!? I will provide the rest of my code if necessary. Please request any details required.
The errors are both the same:
106assig-4.cpp invalid conversion from `void*' to `int**'
Here is my code:
Code:
int **setMem(int **matrixPointer, int rows, int columns) { // Allocate memory for each row. matrixPointer = calloc(rows, sizeof(int *)); //error here!! // Allocate memory for each columns within each row. for (int index1 = INIT; index1 < rows; index1++) { // error on line below matrixPointer[index1] = calloc(columns, sizeof(int)); } return matrixPointer; }
PLease could some one let me know how I can fix this!? I will provide the rest of my code if necessary. Please request any details required.
Comment