how to create a dynamic string array to store string items using new ...

Recommended Answers

All 2 Replies

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.