Possible Duplicate:
cin.getline() is skipping an input in C++
I'm working on C++, to get some data of 2 movies like the following:
struct Movie m1, m2;
cout << "Enter first movie title: ";
cin.getline(m1.title, 30);
cout << "Enter first movie director: ";
cin.getline(m1.director, 30);
cout << "Enter first movie length: ";
cin >> m1.length;
cout << "Enter second movie title: ";
cin.getline(m2.title, 30);
cout << "Enter second movie director: ";
cin.getline(m2.director, 30);
cout << "Enter second movie length: ";
cin >> m2.length;
But, I got surprised that in the output it doesn't all me to enter the title of the second movie. Here is the output
Enter first movie title: Girl
Enter first movie director: GirlD
Enter first movie length: 10
Enter second movie title: Enter second movie director: Boy
Enter second movie length: 20