zoukankan      html  css  js  c++  java
  • Linux-c对一个十六进制数的某一位取反

     1 enum SWITCH_FLAG {
     2   SWITCH_ALL_FLAG       = 0,
     3   SWITCH_WEB_FLAG       = 1,
     4   ……
     5 }
     6 
     7 unsigned int switch_by_bit_value = 0x7FFFFFFF;
     8 
     9 void switch_set_bit(int*a,int position,int flg)
    10 {
    11     int b=1<<position;
    12     if(flg==0){
    13         *a&=~b;
    14     }
    15     else{
    16         *a|=b;
    17     }
    18 }
    19 
    20 switch_set_bit(&switch_by_bit_value,SWITCH_WEB_FLAG,1);
    21 switch_set_bit(&switch_by_bit_value,SWITCH_WEB_FLAG,0);
  • 相关阅读:
    Git Bash关键命令
    一个不需要Log4Net的写日志的简单方法
    未知软件
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
    Linux
  • 原文地址:https://www.cnblogs.com/renweihang/p/8931469.html
Copyright © 2011-2022 走看看