I am a newbie here. Trying to do my assignment.. Here is my code.
Code:
# include <iostream>
# include <ctime>
# include <string>
using namespace std;
int main ()
{
int num_player;
string name[100];
cout << endl << "\tWelcome to game centre. I am Joe, your game instructor.\n"
<< "\t\tSnake and Ladder" << endl << endl
<< " Please enter the number of player [maximum 4 players]:" ;
cin >> num_player;
cout<< endl;
cout << " Enter the " << num_player << " player's name: " << endl;
for ( int j= 1; j <= num_player ; j++ )
{
cout << j << ". " ;
getline(cin,name[j]);
}
cout << endl;
system("PAUSE");
return 0;
}
The output I get have a problem.
System don't allow me to input for name[1];
I don't understand why~
Is it the getline problem?
can someone fix it for me? T^T