I'm trying to build an array / matrix from a command given through stdin. The command is formatted like this:
nameOfArray build numberOfDimensions : dimensionList : valueList
Another example:
B build 1 : 3 : 4,5,6
The command needs to work for up to three dimensions, and I am completely stumped as to how to implement it.
Since we are limited to three dimensions, the problem is easy. We simply treat all the cases as the 3 dimensional case, with height and depth set to one for the lower dimensions.
So we set up the array with malloc() or std::vector::resize() width * height * depth, then read the values in one by one. In C, the job is done. In C++, you might then need to fiddle about to turn your vector into a multi-dimensional matrix class with a nice interface.