cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
what is the matter with this program
what is the matter with this program
May 3, 2009 at 5:33pm UTC
rishamessi
(46)
# include <iostream>
using namespace std;
void readmatrix(int row)
{int column;
cout<<"The Number of Rows=";
cin>>row;
cout<<"The Number of Colums=";
cin>>column;
int matrix1[row][column];
for (int i=0;i<row;i++)
{
for (int j=0;j<column;j++)
{
cin>>matrix1[i][j];
}
}
}
int main ()
{
int row,column;
int matrix[row][column];
readmatrix(matrix[row][column]);
system("pause");
return 0;
}
i want to know why this porgram doesnt run :s
May 3, 2009 at 10:45pm UTC
firedraco
(6243)
First, you can't create matrices with a variable as the number of rows/columns/etc. You must use new (for C++) or malloc/calloc (for C). Secondly, you never define row and column in main.
May 3, 2009 at 11:06pm UTC
Bazzy
(6281)
You can also use vectors, read
http://www.cplusplus.com/forum/articles/7459/
Topic archived. No new replies allowed.