View Single Post
Old Nov 16th, 2006, 3:09 AM   #1
veiga2
Newbie
 
veiga2's Avatar
 
Join Date: May 2006
Location: Philippines
Posts: 21
Rep Power: 0 veiga2 is an unknown quantity at this point
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;
}







}
veiga2 is offline   Reply With Quote