What does '<<' mean in C?

前端 未结 5 1909
一生所求
一生所求 2021-01-07 08:33

what does this mean?

#define WS_RECURSIVE    (1 << 0)

I understand that it will define WS_Recursive (1 << 0) but w

5条回答
  •  甜味超标
    2021-01-07 09:28

    This is a bit shifting to the left. So 1 << 0 is actually 1. It is usually used this way when you want to define some flags, each of them is one bit set, for example:

    #define FLAG1 (1 << 0)
    #define FLAG2 (1 << 1)
    #define FLAG3 (1 << 2)
    #define FLAG4 (1 << 3)
    

提交回复
热议问题