Using a cin in a do while loop

How do I add in cin to every cout that I do in my do while loop
I want to make it so that whatever number of players I put it will ask "enter player " a "'s name." then you would have to enter p1, then it loops and then asks p2 and so on depending on how many players were said there are.


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
using namespace std;
int main(int argc, char** argv) {

int a=1,numPlay,p1,p2,p3,p4,p5,p6,p7,p8,p9;

  cout<<"How many players are there from 2 to 10?\n";
    cin>>numPlay;
    
    do{
        
        cout<<"enter player "<<a<<"'s name.\n";
        a=a+1;
        
        
    }while (a<numPlay+1);

return 0;
}
Last edited on
1
2
3
4
std::string names[10];
do{
   std::cin >> names[a-1]; //index goes from 0 to n-1
}while(a<numPlay+1)
Topic archived. No new replies allowed.