User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 391,815 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,566 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser:
Views: 162 | Replies: 1
Reply
Join Date: Mar 2008
Posts: 19
Reputation: sjgriffiths is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
sjgriffiths sjgriffiths is offline Offline
Newbie Poster

Accessing a pointer array

  #1  
Mar 19th, 2008
Hello

I have the following pointer

char **pOutData;

This contains an array of strings.

How do i printf each element in of pOutData

Hope someone can help
best regards
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2004
Posts: 6,017
Reputation: Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of Narue has much to be proud of 
Rep Power: 26
Solved Threads: 414
Super Moderator
Narue's Avatar
Narue Narue is offline Offline
Expert Meanie

Re: Accessing a pointer array

  #2  
Mar 19th, 2008
Assuming you're using an explicit size variable to store the number of strings:
  1. int i;
  2.  
  3. for ( i = 0; i < n; i++ )
  4. printf ( "%s\n", pOutData[i] );
A common alternative is using a null pointer as a sentinel. In that case, it would look like this:
  1. char **p = pOutData;
  2.  
  3. while ( *p != NULL )
  4. printf ( "%s\n", *p++ );
Last edited by Narue : Mar 19th, 2008 at 11:07 am.
Member of: Beautiful Code Club.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb C Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 5:40 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC