I want to create a matrix of n*1 (a matrix of one column. n
can be any integer)
I think It should be something like:
int mat[][1];
cin >> n;
*mat = new int[n]*;
any help appreciated!
I want to create a matrix of n*1 (a matrix of one column. n
can be any integer)
I think It should be something like:
int mat[][1];
cin >> n;
*mat = new int[n]*;
any help appreciated!
If you declare your matrix as:
int mat[][1];
It means that you are not doing dynamic memory allocation.
You should do the following:
int **mat = new int*[n]; //n is number of rows
for (int i = 0; i < n ;++i)
{
mat[i] = new int[1];
}
Anyway, you should prefer to use std::vector
instead of using dynamic allocated arrays, especially when you have only 1 column.