I am working on a numerical simulation in C and (to simplify the code) I decided to use void functions to change the values in the existing arrays, rather than writing multiple functions or defining structures.
Thanks to a question on this site i learned that I can do this by giving the function a pointer to a pointer as an argument, I did so and tried to make it work this way for example:
void initialization_1(double *x, double **A, double **delta, double **Phi, double **Pi){
int i;
for(i=0;i<SIZE;i++){
(*Phi)[i]=0.0;
(*Pi)[i]=2.0*eps*exp(-(4.0*pow(tan(x[i]),2.0))/pow(M_PI*sigma,2))/M_PI;
}
*A=A_Solver(x, *Phi, *Pi);
*delta=Delta_Solver(x, *Phi, *Pi);
}
And I called it in the main this way:
int main(){
double* x=initialize_x();
double h=x[1];
double A[SIZE];
double delta[SIZE];
double Phi[SIZE];
double Pi[SIZE];
initialization_1(x, &A, &delta, &Phi, &Pi);
return 0;
}
when I try to compile it compiles, but gives me a series of warnings of this type:
warning: passing argument 2 of 'initialization_1' from incompatible pointer type [-Wincompatible-pointer-types]|
note: expected 'double **' but argument is of type 'double (*)[4096]'|
(The compiler is gcc)
I am quite confused, I thought that pointers and arrays were basically the same thing in C, and this is just a warning, should I just ignore it, or should I fix something in my code? Thanks in advance