I have made one function which will get value for m * n matrix.
int *matrix_read()
{
int i,c,r;
static int *q;
cout<<"Enter value of M and N for M * N matrix";
cin>>c>>r;
int *p=new int(r*c);
q=p;
for (i=0;i<r;i++)
{
cout<<"Enter"<< i+1<<"Row value";
for (int j=0;j<c;j++)
{
cin>>*p;
p++;
}
}
return q;
}
Now the problem I am facing is that how can I return the size of the matrix. Means If I want to display the same matrix then I must know the size of the matrix. How can i do this?
int *matrix_read()
{
int i,c,r;
static int *q;
cout<<"Enter value of M and N for M * N matrix";
cin>>c>>r;
int *p=new int(r*c);
q=p;
for (i=0;i<r;i++)
{
cout<<"Enter"<< i+1<<"Row value";
for (int j=0;j<c;j++)
{
cin>>*p;
p++;
}
}
return q;
}
Now the problem I am facing is that how can I return the size of the matrix. Means If I want to display the same matrix then I must know the size of the matrix. How can i do this?
Comment