Define a 2D array with Dynamic Memory

Hi!
First let me say a big Thanks to people who helped me in my early topics.

I want to write a program that takes a number from user and writes a matrix with length and width of that number, but Visual Studio doesn't let me define a 2D array base on that number.
Am I doing it right?
1
2
3
4
5
6
7
8
9
10
11
.
.
.
int a;
int * b;
cout<<"Enter the number";
cin>>a;
b=new int [a][a];
.
.
.


I tried (nothrow) and #include <new> and a mixture of them, but it still didn't work.
Last edited on
b is a pointer. What you need is a pointer to pointers.

int **b; // and it only gets worse from here

Please apply the D3 rule if you can: Don't Do Dat.
http://www.cplusplus.com/articles/NAUq5Di1/
Topic archived. No new replies allowed.