Solved

pointer to pointer as function parameter

Posted on 2012-03-25
3
325 Views
Last Modified: 2012-03-25
Hi Experts,

A function prototype is given as below.  I need to use this to get the Network list.
Result_t Query::queryNetworkList(Network **list, int& size) const

Open in new window

How can I iterate through this list and find all the Network items.
I am thinking something like below.. but not sure how to deal with the list.
Thanks,
Network *list;
int size = 0;
Query q;
q->queryNetworkList(&list, size);
for( int i = 0; i < size; i++ )
{
 ....

}

Open in new window

0
Comment
Question by:ambuli
  • 2
3 Comments
 
LVL 32

Expert Comment

by:phoffric
ID: 37763110
for( int i = 0; i < size; i++,  ++list)
{
    Network currentNetwork = *list;
 ....

}
0
 
LVL 32

Accepted Solution

by:
phoffric earned 500 total points
ID: 37763115
Query::queryNetworkList() should be returning the list pointer (that's why the method takes a **pointer - to allow it to modify and return the value into the caller's list pointer). It also returns the size of the Network List.

++list increments the list pointer by one element (not 1 byte) in the NetworkList array.
0
 

Author Closing Comment

by:ambuli
ID: 37763124
Thank you
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now