Ok so this is pretty straightforward: I want the console to ask me some details about a movie, and then print it nicely. The problem is that this will only take one word for every input. While looking up I found something about getline(); this is where it gets tricky.
When I use getline(cin, title); (etc.) instead of cin << title; the console prints "Title? Year? " on one line and asks only for one input. Then it prints "medium? " and asks for a second input, then it prints the input. So suddenly I have only two inputs instead of three, I don't understand what's happening. In short, this doesn't work:
Well, like is explained in detail in the post I linked, the operator>> extracts input from the stream up to white space, but discards any leading white space. So if you use it more then once any white space that is left in stream is summarily discarded by the next >>. Unfortunately, this means if you are trying to get more then 1 word at the same time you have to use multiple >>. This is where getline comes in. BUT, getline does NOT discard leading white space. So you have to do it manually in the code with a black cin.getline() or something similar. There's also cin.ignore(numberofchars, sentinelchar). With ignore the numberofchars represents the maximum number of chars that ignore will read out of the stream and discard. sentinelchar is a char that, once ignore reaches it, will stop before it hits numberofchar, but which it will still extract and discard. So, for instance cin.ignore(1024, '/n') would extract either 1024 characters from the stream and discard them, or all characters up to and including a newline char, which would also be discarded.