|
multi dimensional array error
i hav a problem bout arrays... why cant i allocate the variable in this array?
thnx for your help
#include<iostream>
using namespace std;
main()
{
int r=1,c=1,r2,c2;
cout<<"Enter the no. of rows you desire for matrix1:";
cin>>r;
cout<<"Enter the no. of coloumns you desire for matrix1:";
cin>>c;
cout<<"Enter the no. of rows you desire for matrix2:";
cin>>r2;
cout<<"Enter the no. of coloumns you desire for matrix2:";
cin>>c2;
if(r2>c)
cerr<<"invalid row input";
int **matri1[]=new int[r][c];// source of error<----- this is it
for(int i=0;i<r;i++)
{
for(int j=0;j<c;j++)
cin>>matri1[i][j];
}
for(int k=0;k<r;k++)
{
for(int j=0;j<c;j++)
{
cout<<matri1[k][j];
}
cout<<endl;
}
}
|