I have a list of 2D arrays:
float a[][9] = { ... }
float b[][9] = { ... }
float c[][9] = { ... }
I want to have another array of pointers that point to each of the 2D arrays, like this:
what_should_be_here?? arr[] = { a, b, c }
How to achieve this?
Use
typedefto simplify declaration. Each of the element of arr isfloat (*)[9]. Say this type isSomeType. Then{a,b,c}means you need an array of three elements of typeSomeType.Now the question is, what is
SomeType? So here you go:As I said, use
typedefto simplify declaration!I would choose a better name for
SomeType:That is a longer name, but then it makes the code readable!
Note that without typedef, your code will look like this:
which is UGLY. That is why I will repeat:
Use
typedefto simplify declaration!Hope that helps.