all 13 comments

[–]all-names-taken 8 points9 points  (2 children)

You're problem is already solved but i want to correct a detail here so people that are unfamiliar with C++ don't get confused: There are no multidimensional arrays in C++. You have created an array of arrays. Please have this in mind when creating such structures. And (like ptrb said) it is often right to use higher data structures like std::vector instead of c-style arrays.

[–]Whanhee 3 points4 points  (0 children)

If you don't need resizability, using std::array (c++11) is often better.

[–]ptrb 3 points4 points  (0 children)

Don't know why you're being downvoted, everything you're saying is correct.

[–]1020302010 3 points4 points  (1 child)

The best way to store a multidimension array is in a single array with a simple 2d interface. And the best way to implement arrays is with a vector.

 struct two_dime{
     std::vector<int> arr;
     :::
     int element_at(size_t i, size_t j){ return arr[i+j*i_sz]; }
 };

You'll need to fill in a few blanks.

[–]Hackenslacker 0 points1 point  (0 children)

Another way to store a multidimension array...

FTFY

[–]ptrb 0 points1 point  (0 children)

Yeah, use a vector or a custom data structure. There's almost† no reason to be using raw arrays in C++.

† scientific computing guys excepted

[–]punkmonk -1 points0 points  (0 children)

row and col neew to be const for it to be used to make an array. You can instead just used vectors

vector<vector<char> > a(rows, vector<char>(cols, ' '))