Jump to content
  • Advertisement

Squiffyk7

Member
  • Content Count

    2
  • Joined

  • Last visited

Community Reputation

108 Neutral

About Squiffyk7

  • Rank
    Newbie
  1. Squiffyk7

    C++ skips a statement in it's first run

    And it works! Thanks, although I'm not to sure what's changed, I think I need to look further into what streams are before I move on.
  2. Hello, i've been learning how to write in C++ using the tutorials on www.cplusplus.com for currently 3 days, so ofcourse my code will look very ammaturish. As I'm getting to grips with the syntax, i'm working on a simple program that lets you name how many films are your favourite, and specify what those films are called. Obviously its rather pointless, but as I said I'm practicing what i've learnt from the C++ syntax so far. 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.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!