By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,387 Members | 1,757 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,387 IT Pros & Developers. It's quick & easy.

How to return array

P: 30
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";
int *p=new int(r*c);
for (i=0;i<r;i++)
cout<<"Enter"<<i+1<<"Row value";
for (int j=0;j<c;j++)
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?
Oct 1 '06 #1
Share this Question
Share on Google+
4 Replies

P: 23
Make your matrix a class with members that specify the dimensions...
Oct 1 '06 #2

P: 30
the thing is I have to do this task using only function. That is why I am confused.
Oct 2 '06 #3

Expert Mod 5K+
P: 8,916
You pointer parameters to point to locations to store the width and height

int *matrix_read(unsigned *pWidth, unsigned *pHeight)
Oct 2 '06 #4

P: 41
note: you have to free memory references by the returned pointer after using it
Oct 2 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.