Simple for others , not for me

Simple for others , not for me.
How do you allocate memory for an array of pointers, each pointer pointing on a string.
The problem is , that the size of the array could change depending on the number of strings the user wants to enter.
This needs to be done in a function.
There are other functions needed to be written from the main.
At least get me started
You want dynamic allocation. Look in to new and delete. GL
(although there is non-standard support for dynamic size array allocation on the stack for gcc. it's cool, but very much non-standard)
If you can determine the number of strings needed before allocating the memory, a simple dynamic array will suffice:
 
string * arrayofstrings = new string [numberofstrings];

for more info see: http://cplusplus.com/doc/tutorial/dynamic.html

If the number of strings to be input cannot be determined beforehand, you can use a vector:
 
vector<string> vectorofstrings;

for more info see: http://cplusplus.com/vector
Topic archived. No new replies allowed.