In my attempt to gain a less superficial understanding of it, I learned that the >> operator, which is usually presented to newbies with cin>>var; examples, reads right-to-left.
That is.
cin >> var;
in which cin is a specialized input stream and var; is the input being read (right-to-left, by the operator) into the cin stream.
Now, I know that in a given program's complex communication with the operating system (and by extension, the hardware) there exists a process which collects my input characters from whatever (keyboard, etc.) encapsulates it in a buffer, and gives the buffer to the istream to convert to objects of data types. Correct me if my understanding is wrong or (more than trivially) incomplete.
So.
Once my istream receives the characters or what-have-you and converts them to objects of types, is that when it gets stored in the var? Or does it get stored in the var before the istream receives the data object?
In the case of
1 2
|
cin >> a >> b >> c;
cout << a << b << c;
|
The cin stream collects the input from my keyboard and the cout stream sends it to my monitor.
If I typed 3 2 1
My output would be 3 2 1
My impression here is that the istream (somehow) stores the input into the variables and THEN reads the >> operator(s) which places the return value(s) of the operand variable(s) in the stream.
However, this case would still confuse me, because my impression is that >> reads right-to-left. So why, when I "stack" variables as with the statement
cin >> a >> b >> c;
does it read the values in the buffer into the variables in left-to-right order?
Does my misunderstanding lie with how istreams work, or with how the >> operator works?
EDIT: Or is there a two-fold standard whereby the typed values are read into the variables left-to-right, while the variables are read into the stream by the operator right-to-left?