I want to initialize values of 2-D array to 0. But it seems not to work. Can I initialize values of my **array in constructor to be 0. If yes the How. My code is.
#include <iostream>
using namespace std;
int main(){
int row, col;
cin>>row;
cin>>col;
int **array=new int*[row];
for (int i=0; i<row; i++){
array[i]=new int[col];
}
for (int i=0; i<row;i++){
for (int j=0; j<col; j++){
array[i][j]={'0'};
cout<<array[i][j]<<" ";
}
cout<<endl;
}
}
Further can someone explain if I have to replace ith elem from the array with some other element, how would I deal with memory allocation.