#include<stdio.h>
#include<stdlib.h>
float** makeMatrix(int n, int m) { // I don't understand why there are two **
float* memoryPtr;
float** matrixPtr; // Here, there are two again. Howcome?
int i;
memoryPtr=(float*)malloc(n*m*sizeof(float));
matrixPtr=(float**)malloc(n*sizeof(float));
if (memoryPtr==NULL || matrixPtr ==NULL) {
fprintf(stderr, "Not enough memory \n"); //Please explain this line also.
exit(1)
}
for(i=0; i<n, i++, memoryPtr += m) { //Please explain the for loop also.
matrixPtr[i] = memoryPtr;
}
return matrixPtr;
}
Thank you very much for your help.

New Topic/Question
Reply




MultiQuote




|