N x N Matrix

I need to take an input from a user and create an N x N matrix using the user input. I can't figure out a way to get an input from a user and be able to set up a 2D array to start my matrix. If anyone knows how I would greatly appreciate it!
You can use the stl containers fairly easily for this or the old way:
1
2
3
4
5
6
7
8
9
10
11
std::cout << "Please enter size of array(NxN): ";
int n;
std::cin >> n;

int **array = new int *[n];

for(int i = 0; i < n; ++i)
    array[i] = new int[n];


//don't forget to delete the stuff that was new'd 
Last edited on
Topic archived. No new replies allowed.