I'm new to C++, if anyone can help me, i'll be grateful.
The question is a follow:
User will be asked to key in the number of players (maximum 5 players) that challenge each other for top ranking. Their name will then be taken in one by one. Assume the names will not exceed 29 characters including spaces.
My question is how to store the name into an array. I only know how to store one player's name into it. And why is it always start with the 2nd participants instead of the first one??
Here is my code:
Code:#include<iostream> using namespace std; int main(void) { int no_participants; int crtl_1; char name_participants[30]; cout<<"Please enter the number of participants (1-5):"; cin>>no_participants; for (crtl_1=1; crtl_1<=no_participants; crtl_1++) { cout<<"Please enter the name of participants "<<crtl_1 <<":"; cin.getline (name_participants, 30); cout<<endl; } cout<<name_participants; cout<<endl; return 0; }



LinkBack URL
About LinkBacks



