Another way is to pass the double pointer as a reference:
- petterCode:void alloc_data(float** &data) // pass reference (to the double pointer) { int i, nx, ny; nx = 3; ny = 3; data = (float **) calloc(nx, sizeof(float *)); for (i=0; i<nx; i++) data[i] = (float *) calloc(ny, sizeof(float)); } int main(int argc, char *argv[]) { float **data; alloc_data(data); }




Reply With Quote