+ 1
What is the use of >> in c++?
plz
5 ответов
+ 8
Aaaaaa I keep forgetting >> and << do something else! >_<
+ 1
It is an operator so it can be override but its first use is to do a binary offset to the right.
Example :
7 in binary is 000111 (I don't know how many zero there is to the left)
7>>1 is 7 with one shift to the right so it gives 000011 which is 3 in decimal
7>>2 is 7 with two shifts to the right so it gives 000001 which is 1 in decimal
7>>3 is 7 with three shifts to the right so it gives 000000 which is 0 in decimal
+ 1
<< is like >> but the offset is done to the right :)
+ 1
easiest way to remember which is used for what..
the one pointing to the right >>
is the one used for write (input from user)
which will then remind you that << is for output
+ 1
>> is the bitwise right shift operator. see post https://www.sololearn.com/Discuss/173715/?ref=app