Note that there are some explanatory texts on larger screens.

plurals
  1. POArray of 2d arrays
    text
    copied!<p>My question is difficult to describe, and I have two tables containing lots of numbers respectively; for one table, I search format through index </p> <pre><code>table1 index format +------+----+ |0~19 | 0 | | | | +------+----+ |20~29 | 1 | | | | +------+----+ |30~39 | 2 | | | | +------+----+ table2 index resource(f,t0,t1,t2) 0 1 2 3 (configure type) +----+-----------+---------+---------+ |0 | (0,1,0,2) |(0,1,0,1)|(0,1,0,0)| +----+-----------+---------+---------+ |1 | (0,2,0,2) |(0,2,0,1)|(0,2,0,0)| +----+-----------+---------+---------+ |-- | (0,0,1,2) |(0,0,1,1)|(1,0,0,0)| +----+-----------+---------+---------+ |19 | (0,0,0,0) |(0,0,0,0)|(0,0,1,1)| +----+-----------+---------+---------+---------+ |-- | (0,0,0,2) |(0,0,0,1)|(0,0,1,0)|(0,2,1,0)| +----+-----------+---------+---------+---------+ |29 | (0,1,0,2) |(0,1,0,1)|(0,1,0,1)|(0,1,0,1)| +----+-----------+---------+---------+---------+ </code></pre> <p>Hopefully,the following code snippet can make me understood,</p> <pre><code>typedef struct my_struct { int f; int t0; int t1; int t2; } my_struct; // for index 0 ~ 19, the following is code snippet my_struct format0[2][3] = { {{0, 1, 0, 2}, {0, 1, 0, 1},{0, 1, 0, 0}}, // index 0 {{0, 2, 0, 2}, {0, 2, 0, 1},{0, 2, 0, 0}} // index 1 }; // for index 20 ~ 29, the following is code snippet my_struct format1[1][4] = { {{0,0,0,2},{0,0,0,1},{0,0,1,0},{0,2,1,0}} // index 20 }; </code></pre> <p>I have multiple 2d arrays containing resources grouped by <code>format</code>, each has different dimensions for different <code>format</code>, rowed by <code>index</code>, coled by <code>configure type</code> like 0,1,2..6, so I want to put them into another 1d array in order to look up easily through index, and get resource finally, but I don't know how.</p> <p>I have tried the following but failed:</p> <pre><code>my_struct* group[] = { format0, format1 }; </code></pre> <p>then using <code>group[0]</code>, I can get <code>format0</code>, but I find it forgot its <code>[1][2]</code> which I need to know, so I am wondering there is some solution help me do that?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload