this is the code that i add the dynamic array.did you know how to arrange the name so it can be display like the output.
Code:
#include<iostream>
#include<string>
using namespace std;
int main()
{
int people;
int i=1;
string* newname;
string names;
cout << "How many people are there? (1 to 10) " << endl;
cin >> people;
while(people<1 || people>10)
{ cout << "Maximum size should be between 1 to 10" << endl;
cout << "Please re-enter the number of people: " << endl;
cin >> people;
}
newname = new string[people];
cout << "Enter first person's name: " << endl;
cin >> names;
for(i=1; i<people; i++)
{
cout << "Enter the next person's name: " << endl;
cin >> newname[i];
}
delete [] newname;
newname = 0;
system("pause");
return 0;
}