Dec 12, 2011 at 6:13am UTC
First of all I am a student working on my final all I know so far is plain old c++, nothing more. I am working on my class final, it is a Video Store Program and I am trying to get it to accept names of movies. Such as The Big Bounce, Star Wars. So I know I need getline. But everytime I execute it completely skips over my getline. Please Help its due in three days.
Here is the part of my code i am messed up on.
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <ctime>
#include <sstream>
using namespace std;
int main ()
{
int which;
string movies[100][20];
int howmanyMovies[100];
cout << "Which customer is renting ? : ";
cin >> which;
cout << "What is the name of the movie ? : ";
getline (cin,movies[which][ howmanyMovies[which]]);
cout << movies[which][ howmanyMovies[which]];
cout << endl << "Have a nice day!" << endl << endl;
system("pause");
return 1;
}
(PS I am not looking for someone to do my homework, I just to know how to fix this to continue on with the rest of my code)
Dec 12, 2011 at 9:09am UTC
Skips you say?
Well, try placing cin.ignore()
right in front of your getline and see what happens. It should (hopefully), be fixed now.
Last edited on Dec 12, 2011 at 9:10am UTC
Dec 12, 2011 at 9:11am UTC
Next time you post, you might want to consider using code tags... makes the post look nicer, and also helps us read it better.
Welcome to the forum!
Last edited on Dec 12, 2011 at 9:11am UTC