I have written code below that contains a function with a pointer to a double array of size 3.My problems is this: when I pass the address of pointer to a double variable (that clearly isn't an array) and then want to change the value of this double variable in function "f" as written below, when I implement in this manner, the result is correct and the value of the variable is changed:
#include <stdio.h>
void f(double (*)[3]);
double a = 7.5;
int main()
{
double* b = &a;
f(&b);
printf("a = %lf\n", a);
return 0;
}
void f(double (*hi)[3])
{
double **sth = (double **) hi;\
*(*sth) = 1;
}
But when I implement as below the value isn't changed:
void f(double (*hi)[3]){
(*hi)[0] = 1;
}
Any idea and suggestion is surely appreciated.