Some time ago I did half the tutorial about C++ programming, and because its a while ago I am going trough it for a second time. But I just noticed I never really knew why u have to use << or >> and what the difference in them is (offcourse i know u have to use it like when u use cout << "hello world";) but i was wondering what exactly the use off << or >> in particular means and why to use it.
Maybe i just asked a complete stupid question but i'm writing everything down to remember it better, but in the part about cout << "hello world"; everything is explained except <<
<< and >> are operators, their 'real' meaning is bit shifting ( http://en.wikipedia.org/wiki/Arithmetic_shift )
But as in C++ operators are overloaded, in streams >> means 'get formatted input' and << 'give formatted output'
so:
1 2 3
string str;
cin >> s; // gets a string from the user
cout << s; // displays the string