I am getting an segmentation fault when I pass the double pointers to the function to initialize the memory
int main()
{
double **A;
initialize(A, 10, 10);
......
}
void initialize(double **A, int r, int c)
{
A = (double **)malloc(sizeof(double *)*r);
for(int i = 0; i< r; i++) {
A[i] = (double *)malloc(sizeof(double) *c);
for(int j = 0; j < c; j++) {
A[i][j] = 0.0;
}
}
}
How can I pass the double pointers to the functions.....
If you want to modify a pointer to pointer you need to pass a pointer to pointer to pointer.
void func(double ***data) { *data = malloc(sizeof(double*)*10); for.... };
double ** data; func(&data);