F
Francogrex
I'm confused about 2 dimensional arrays and there memory storage and
how to handle them using pointers; for example below something is
wrong but can't spot why?
#include <stdio.h>
#include <stdlib.h>
double **test ()
{
double **arr =malloc(100);
arr[0][0] = 5.6;
arr[0][1]=17.4;
return arr;
}
int main ()
{
double **myarray;
myarray=test();
printf("%f -- %f", myarray[0][0],myarray[1][1]);
}
// result: 5.600000 -- 17.400000 but expected to give error of
myarray[1][1] not 17.400000
how to handle them using pointers; for example below something is
wrong but can't spot why?
#include <stdio.h>
#include <stdlib.h>
double **test ()
{
double **arr =malloc(100);
arr[0][0] = 5.6;
arr[0][1]=17.4;
return arr;
}
int main ()
{
double **myarray;
myarray=test();
printf("%f -- %f", myarray[0][0],myarray[1][1]);
}
// result: 5.600000 -- 17.400000 but expected to give error of
myarray[1][1] not 17.400000