I cannot spot the issue and neither can VS2010/ VS11 Developer preview edition. The code runs perfectly until allocating memory for the double pointer new_matrix. The only reason I cannot find the problem is because I've allocated space for 3 other pointers successfully. I believe I have the syntax correct since I followed exactly what I had before with minor adjustments. Any help would be greatly appreciated!
//Variable Declaration and initialization int **matrices = (int **) malloc(4 * sizeof(int)); //Pointer to the set of matrix registers int *rows = (int *) malloc(4 * sizeof(int)); //Pointer to hold row sizes int *columns = (int *) malloc(4 * sizeof(int)); //Pointer to hold column sizes. Memory_Allocation(matrices[Matrix_ctr], Matrix_ctr); //Allocate space for user data.
void Memory_Allocation(int matrices, int Matrix_ctr);
void Memory_Allocation(int **new_matrix, int matrix_Index) ... new_matrix = (int **) malloc(size * sizeof(int)); //The pointer was not initialized to NULL.
I am calling the function Memory_Allocation from my main.c file which takes in a double pointer as an argument. This pointer will point to **matrices to hold all of the user's matrices in the end.
Thanks for your help!:)