I wrote a sentinel-controlled C++ program in which you have to input a set of names. There is no limit to how many names you can input. When you are done inputting the names, you just type "1" to quit. Here is my code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
int nofPeople = 0;
cout<<"Enter a name or 1 to quit:\n";
cin>>name;
while(name != "1")
{
nofPeople = nofPeople + 1;
cout<<"Enter another name or 1 to quit:\n";
cin>>name;
}
}
Now I want to create an array with length that equals 'nofPeople' and I want the elements of that array to be the names that I already entered. How do I do that?