473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to return array

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?
Oct 1 '06 #1
4 6152
m013690
23
Make your matrix a class with members that specify the dimensions...
Oct 1 '06 #2
the thing is I have to do this task using only function. That is why I am confused.
Oct 2 '06 #3
Banfa
9,065 Expert Mod 8TB
You pointer parameters to point to locations to store the width and height

int *matrix_read(unsigned *pWidth, unsigned *pHeight)
{
...
}
Oct 2 '06 #4
ltgbau
41
note: you have to free memory references by the returned pointer after using it
Oct 2 '06 #5

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

Similar topics

0
by: the gullers | last post by:
I am trying to return an array of strings (basicaly the contents of the textfield) to the main class... when i put this piece of code it tells me that i need to declare the array of strings final...
0
by: Marc van Boven | last post by:
I'm stuck with the following problem: My nusoap-client calls a server-function giveCombination(). The function giveCombination should return something like array( => array( 'a_id' => 6,...
16
by: priya | last post by:
Hi all, I am new to this group.I am working in c language.I have dount in pointer? how to retun array of pointer in function? example main()
2
by: kathy | last post by:
how to return array from function?
2
by: Ali | last post by:
hi i need to send some data to the function and want to return array of object bac lik dim obj() as myclass=AddIt(i,j i dont know that is write syntax or no public function addit(byval i as...
5
by: Sam | last post by:
Hi All I have couple of question regarding property of a class and structures. **** ---- Here is my class and structure ---- ***** 1. Public Structure MyPoint 2. Dim p As Point 3. ...
0
by: anthony | last post by:
I have a dataset filling an array from the database Dim ds As DataSet = New DataSet da.Fill(ds, "table") returnResults = ds.Tables("table").Select I want to return the array to the asp...
10
by: Raj | last post by:
I need a VB function to return array of collections like Private Type Employee empname as string address as string salary as integer deptno as integer End Type dim employees() as Employee
5
by: Igoogler | last post by:
I am currently trying to return an array from curl and it doesn't seem to be working. What I basically want it to is to search the remote page for some text and then perform and If Then statement. ...
1
by: =?Utf-8?B?RGFya3Jpc2Vy?= | last post by:
Mates, the problem is pretty simple, but I'm unable to manage it... Therefore asking you for help. Situation: Have managed code in C# and unamanged code in C++ DLL. I need to make a call from...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.