I have simple OpenGL C program (from NeHe lesson 2). There is initialization function InitGL.
And i have function foo in my static library:
void foo(double *p)
{
p[0] = 1.0;
}
When i define array of double at start of InitGL:
double arr[1000];
and modify it in InitGL all works fine.
When i allocate memory for this array dynamically and call foo from InitGL all works fine too:
double *p = (double *)malloc(1000 * sizeof(double));
foo(p);
But when i define array at start of InitGL and call foo from InitGL:
double p[1000];
foo(p);
i get segmentation fault at line
p[0] = 1.0;
Where is the error?
Silver_Ghost’s edited question, entered here so the question doesn’t show up as having 0 answers: