943,634 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 6754
  • C++ RSS
Aug 31st, 2008
0

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

Expand Post »
how to create a dynamic string array to store string items using new ...
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
vijaysoft1 is offline Offline
81 posts
since Jun 2008
Aug 31st, 2008
0

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

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Aug 31st, 2008
0

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

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.
Reputation Points: 10
Solved Threads: 1
Newbie Poster
entei is offline Offline
6 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: c++ help function call
Next Thread in C++ Forum Timeline: Help with FOR LOOP problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC