0

I tried to input numbers in arr[n][m], but there is the problem, that numbers in an array should be constants, that's why I tried to do this:

int n,m;
cin>>n>>m;
int *arr= new int[n][m];

But it doesn't work for m, what should I do?

S.S. Anne
  • 15,171
  • 8
  • 38
  • 76

1 Answers1

0

Although you are suggested to use std::vector. But as per question to allocated 2-D array you should do.

int row,column;
cin>>row>>column;
int** arr = new int*[row];
for(int i = 0; i < row; ++i)
    arr[i] = new int[column];

Go there for vectors

Nikhil Badyal
  • 1,589
  • 1
  • 9
  • 20