As others already pointed out, you don't need to dynamically allocate memory, you might use the stack, instead.
With
C++
you have more options, you could, for instance, use a
std::vector
or a
std::array
.
Try
#include <iostream>
#include <vector>
#include <array>
using namespace std;
int main()
{
vector < vector < unsigned char > > v{{92, 124, 47}, {196, 254, 196}, {47,124,92}};
cout << static_cast<unsigned>(v[1][2]) << endl;
array< array< unsigned char , 3 >, 3> a{{{{92, 124, 47}}, {{196, 254, 196}}, {{47,124,92}}}};
cout << static_cast<unsigned>(a[1][2]) << endl;
}