Hi, I'm new here and I just need a little help with pointers and 2D arrays. I'm kind of new to programming so this might be redundant. I'm trying to make a 2D array of pointers (already have done) that points to another 2D array of double values... I have the code:
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
ptrA[i][j] = a[j][i];
**its transposed for a reason**
However when I do calculations on array ptrA, it doesnt change the values in array a...
ptrA and a are declared by
double a[n][n];
double temp;
for (i = 0; i < n; i++){ //intializing [A] to inputs
for (j = 0; j < n; j++){
scanf("%lf", &temp);
a[i][j] = temp;
}
}
double **ptrA = malloc(n*sizeof(*ptrA));
if (ptrA != NULL){
for (i = 0; i < n; i++)
ptrA[i] = malloc(n*sizeof(*ptrA[i]));
} else return 1;