/*
* This function is to help you dynamically allocate
* memory for a generic 2D Environemnt.
*/
Env make_env(const int rows, const int cols) {
Env env = nullptr;
if (rows >= 0 && cols >= 0) {
env = new char*[rows];
for (int i = 0; i != rows; ++i) {
env[i] = new char[cols];
}
}
return env;
}
/*
* This function is to help you delete a
* dynamically allocated 2D Environment.
*/
void delete_env(Env env, int rows, int cols) {
if (rows >= 0 && cols >= 0) {
for (int i = 0; i != rows; ++i) {
delete env[i];
}
delete env;
}
return;
}