I am trying to understand pointers in c/arduino, and its giving me problems :)
I have a function that creates and returns a pointer to an array of floats:
float* CreateArray(int i) {
float test[2];
test[0] = float(i+1);
test[1] = float(i+2);
return test;
}
I have also defined a multidimensional array:
float data[2][2];
Before I do anything I expect data to look like this: (which it does)
0 0
0 0
When I run the following code:
float* array = CreateArray(22);
*data[1] = *array;
I expect data to look like this:
0 0
23 24
But it looks like this:
0 0
23 0
Somehow the information that the created array was a float[2] is lost, and when I try to cast it to float[2] I get:
ISO C++ forbids casting to an array type 'float [2]'