I have multidimensional array
double coeff[10][3][12][519][11];
and I set the values for this array in a include-file ( #include "call_of_functions.h") in another function:
#include <stdio.h>
void func_T5_D1(double s, double t, double mt, double coeff[10][3][12][519][11])
{
#include "call_of_functions.h"
}
and I call this function in main.c
int main(){
double s, t, mt;
double coeff[10][3][12][519][11]={0};
double ex;
printf("enter 3 values for s, t and mt:\n");
scanf("%lf %lf %lf", &s, &t, &mt);
printf("%lf %lf %lf\n", s, t, mt);
func_T5_D1( s, t, mt, coeff);
ex = coeff[5][1][10][309][10];
printf("%.14e \n",ex);
return 0;
}
However I get a segmentation fault. If I include the #include "call_of_functions.h" in main.c, it works well.
- How can I return the values of this 5 dimensional array in main?
- Or there is another alternative way to do that?
-gflag forgcc), then run in a debugger. When you run in a debugger, it will stop on the location of the crash, and there you can examine and even walk up the function call stack, and examine the values of variables. At least edit your question to include the function call stack (use the commandbtin the debuggergdb).coeffarray is around 16 MB in size, so you probably have a stack overflow - either make itstatic(quick and dirty fix) or allocate it dynamically withmalloc(proper fix).