how to create a dynamic string array to store string items . plz

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 64
Reputation: vijaysoft1 is an unknown quantity at this point 
Solved Threads: 0
vijaysoft1's Avatar
vijaysoft1 vijaysoft1 is offline Offline
Junior Poster in Training

how to create a dynamic string array to store string items . plz

 
0
  #1
Aug 31st, 2008
how to create a dynamic string array to store string items using new ...
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,343
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1458
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: how to create a dynamic string array to store string items . plz

 
0
  #2
Aug 31st, 2008
By "string" do you mean std::string or a character array?

Character array:
char *str = new char[1234]; Just replace 1234 with the desired length, which can be a variable.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 6
Reputation: entei is an unknown quantity at this point 
Solved Threads: 1
entei entei is offline Offline
Newbie Poster

Re: how to create a dynamic string array to store string items . plz

 
0
  #3
Aug 31st, 2008
you cannot dynamically change the size of an array, you can only create a new one and copy the old array, but i gues you could use poiters for you array holder like Ancient Dragon suggested, but thats tricky to manage, an easier option would be to use c++ vector to hold your dynamic array of strings. depending on whether all you'll do is to iterate through the list without, you could consider using a linked list array.

Hope this helps you more than confuse you.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC