The error in my code is not preventing execution, it's just not doing what I want it to do.
// A program that lets you name "n" films.
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main ()
{
int n, i;
string quant;
cout << "How many favourite films do you have?" << endl;
cin >> quant;
stringstream(quant) >> n;
cout << "What are your " << n << " favourite films?" << endl;
string n_movie[n];
for (i = 0; i < n; i ++)
{
getline(cin, n_movie[i]);
cout << "Movie " << i << " is: " << n_movie[i] << endl;
}
return 0;
}
Once I run the code, I can enter my number but the console straight away also prints "Movie 0 is: " without allowing me to specify what movie movie 0 is. I can enter all movies up to movie n-1 as i should be able to.Thanks in advance.