Hi,
This is probably, a really novice question, but I have some code that is using the malloc() function to declare an array, the problem is that I am using a special compiler to compile code for hardware which gives me a lot of errors because of the stdlib.h header file. My code looks as follows:
double (*x)[2]; // Pointer to variable is declared
x = malloc(2 * N * sizeof(double)); //Memory is allocated
//Then I fill the array
for(i=0; i<N; i++)
{
x[i][0]=data[i];
x[i][1]=0;
}
//The array is then passed to a function
function(x);
In the header file which includes the function
void function(double (*x)[2]);
//The variable is then used as "x" to perform calculations
So I would like to declare it without using the malloc() function. Is it possible to that, and how would I declare the variable, I have tried a simple double x[N][2]; , and passing that to the function but I get compilation errors when I do that.
Thanks you,
Sam