void Insert_into_2D_Array(int** foo, int x_pos, int y_pos, int x_size, int y_size)
{
int insert_value = 10;
if (x_pos < x_size && y_pos < y_size) {
foo[x_pos][y_pos] = insert_value; // insert_value lost post func exit?
}
}
void Init_2D_Array(int** foo, int x_size, int y_size)
{
foo = new int*[x_size]; // new alloc mem lost post func exit ?
for (int i=0;i<x_size;i++)
{
foo[i] = new int[y_size]; // new alloc mem lost post func exit
}
}
int main(int agc, char** argv)
{
int** foo;
int x_size=10, y_size=10;
Init_2D_Array(foo, x_size, y_size);
Insert_into_2D_Array(foo, 3,3, x_size, y_size);
}
void Insert_into_2D_Array(int** foo, int x_pos, int y_pos, int x_size, int y_size)
{
int insert_value = 10000;
if (x_pos < x_size && y_pos < y_size) {
(foo)[x_pos][y_pos] = insert_value; // insert_value lost post func exit
}
}
void Init_2D_Array(int*** foo, int x_size, int y_size)
{
*foo = new int*[x_size]; // new alloc mem lost post func exit
for (int i=0;i<x_size;i++)
{
(*foo)[i] = new int[y_size]; // new alloc mem lost post func exit
}
}
void main(){
int** foo = NULL;
int x_size=10, y_size=10;
Init_2D_Array(&foo, x_size, y_size);
Insert_into_2D_Array(foo, 3,3, x_size, y_size);
cout<<"############# "<<foo[3][3]<<endl;
}
void Insert_into_2D_Array(int** foo, int x_pos, int y_pos, int x_size, int y_size)
{
int insert_value = 10;
if (x_pos < x_size && y_pos < y_size) {
foo[x_pos][y_pos] = insert_value; // insert_value lost post func exit
}
}
int** Init_2D_Array(int x_size, int y_size)
{
int** foo = new int*[x_size]; // new alloc mem lost post func exit
for (int i = 0; i<x_size; i++)
{
foo[i] = new int[y_size]; // new alloc mem lost post func exit
}
return foo;
}
int main()
{
int** foo;
int x_size = 10, y_size = 10;
foo = Init_2D_Array(x_size, y_size);
Insert_into_2D_Array(foo, 3, 3, x_size, y_size);
return 0;
}