I'm sure that I'm going to sound dumb on that one but I can't figure out why this simple code isn't working correctly. I just ask the name of the players and put them in an array. The problem is when I print out the name, I'm missing the first character except for the first player...is there a way to fix that? thanks
here is the part of the code posing problem:
oh and by the way can you tell me why I need to use cin.ignore()oh and by the way can you tell me why I need to use cin.ignore()Code:#include<iostream> #include<cstring> using namespace std; int main() { int player; cout<<"number of players: "; cin>>player; char name[player][30] for (x=1; x<=player;x++) { cout<<"player "<<x<<" enter your name please\n"; cin.ignore(); cin.getline(name[x-1],30); } //this part is just to test for (int i=0; i<player;i++) { cout<<name[i]<<"\n"; } }
??
thanks a lot
bart