Hello,

I have a quick question: How do I declare array of strings with a static size entered by user during run time in C++?

In C# i'd do

// Get user unput (int, # of strings);

string[] stringArray = new string[numOfStrings];

//tell user to start imputing the string

But I'm lost with C++. Thank you for your help!!!

Re: Declaring an array of strings in C++ 80 80

I think

#include <string>

was the key to my question. Sorry, newb here.

Re: Declaring an array of strings in C++ 80 80

you have to declar the array as a pointer.

// Get user unput (int, # of strings);

string* stringArray = new string[numOfStrings];

//tell user to start imputing the string
Be a part of the DaniWeb community

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