make a list using 2D Array

hi guys........i'm shofi. i am beginner in C++.
how can i make list of 'n cities using 2D Array.

Sample screen input/output:

-How many cities do you want to enter?

-Please enter the names of the 5 cities:
>>New York
>>Washington DC

-You entered 5 cities: New York, Chicago, Washington DC, Boston and Seattle

can anyone help me about this .... i don't get from where i can start because i very beginner in C++
what is the 2nd dimension of that array for, if you only want to save names?
If the OP has been given that as a requirement, then presumably the names are to be stored as char arrays, rather than as STL strings.
so how can i do this one-array?

Use an array of std::string objects. Technically, that's a 1D array, although each string object probably contains a char array hidden inside it.
can i get some code , please.
i would use a string vector std::vector<std::string> cities;

you can add cities at the end with cities.pushback("New York");
and use cities[0] to get the data.

Topic archived. No new replies allowed.