Hello, I am sorry to clutter this board which obviously has bigger problems than this with such a simple and possibly stupid question, but I am one of those people that cannot tolerate simply "accepting" that "that's how it works." If I don't understand it, I just can't live with it. So here goes.

This is code from the Intro to C++ tutorial:

Code:
#include <iostream>
 
using namespace std;
 
int main()
{
  int thisisanumber;
 
  cout<<"Please enter a number: ";
  cin>> thisisanumber;
  cin.ignore();
  cout<<"You entered: "<< thisisanumber <<"\n";
  cin.get();
}
It says on the page that cin.ignore() throws out the Return key input, presumably leaving only the numerical data.

However, what I don't understand is this: If the cin>> function has already executed, then the enter key would presumably already have been read into the variable thisisanumber. That being the case, how does cin.ignore() know that it's throwing out the last input char on that variable without being fed the variable name?

I could understand if they executed simultaneously, but I'm assuming execution is line-by-line. You reach cin>>, and then the program is waiting for the input, fed in by, and including, the enter key. So now this enter key input is sitting in the variable. Then we execute "cin.ignore()" - but ignore what? How does it know it's ignoring that enter key in that variable?

Sorry for explaining twice but I wanted to make sure it was apparent what I was asking.

Thanks a lot,
-summit45