954,506 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Declaring an array of strings in C++

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!!!

DynamitMsk
Newbie Poster
14 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

I think

#include

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

DynamitMsk
Newbie Poster
14 posts since Dec 2006
Reputation Points: 10
Solved Threads: 0
 

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
Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You