Bo said:
But I will get another error if I do
e[1][1]
how to avoid this? I don't want to write
e[1*11+1] every time!
you could write a function
size_t get_index(size_t i, size_t j)
{
return i*11+j;
}
and use like this
e[get_index(1, 1)] = 0;
or get rid of the pointer and use a reference to a 2d array
typedef int row[11];
typedef row array2d[11];
array2d e;
array2d & eref = e;
eref[1][1] = 0;
since you're using C++, why not use vector instead
#include <vector>
typedef std::vector<int> row;
typedef std::vector<row> array2d;
array2d my_array(11, row(11, 0));
my_array[1][1] = 0;
array2d & my_array_ref = my_array;
my_array_ref[1][1] = 0;