c++ - How to make a program declare variable number of indefinite size arrays -
this might sound crazy wondering if possible make program declare n
number of arrays of type array[]
in loop using c/c++. example, sample pseudo-code:
input int _n_ run loop _n_ times such that: declare _array1[]_ declare _array2[]_ . . declare _array'n'[]_
so problem here two-fold:
- declare variable length arrays
- declare variable number (i.e. n number of) such arrays.
the truth table:
task / language | c | c++ -------------------------------+-----------------------+------------------------ declare variable length arrays | use vlas | not possible without | int arr[n]; | non-standard extensions | | use std::vector<t> -------------------------------+---------------------+-------------------------- declare variable number | not possible | not possible use (i.e. n number of) such arrays | use int arr[n][k]; | vector<vector<t>>
Comments
Post a Comment