Solved

pointer to pointer as function parameter

Posted on 2012-03-25
3
324 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use nested-loops in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

760 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

24 Experts available now in Live!

Get 1:1 Help Now