I want to make an array of pointers, where each one points to a 2D array of floats. The 2D arrays are defined like this
float a[][2] = {{1,0.5},{2,0.5},{3,0.5},{4,0.5}};
float b[][2] = {{1,1},{5,1},{4,0.5},{3,0.5},{2,0.5},{8,1}};
float c[][2] = {{1,0.333},{1,0.333},{1,0.334}};
Each one has a different amount of rows, but always 2 columns. I also have a function where I send one of those arrays as an argument, and need to use some values in them. Let's say it's something like this (there are other things related to other values I need to use, but it's not too relevant to the question)
void take_values(float arr[][2]){
printf("%f ", arr[0][0]);
printf("%f ", arr[0][1]);
}
In main(), I've been using the function on each of the arrays like this
take_values(a);
take_values(b);
take_values(c);
I want to find a way to iterate that function over each array. I was thinking of making an array of pointers referencing each 2D array, but I don't know how to define and use it.
- How can I define the array of pointers to each of the 2D arrays?
- How can I send the 2D arrays as arguments in the
take_valuesfunction, using that array of pointers? - How would I access the specific values of the arrays inside the
take_valuesfunction? / Do I need to use pointers there as well or just keep it the way it is now?