/********************************************************************** * RightMove.cpp * Compiler: GCC,VS,VC6.0 win32 * Author:WK * Time: 2015 3 29 ************************************************************************/ #include<stdio.h> void bit_set(unsigned int *p_data, unsigned int position, bool flag) { if(flag) { *p_data |= (0x01<<(position-1)); } else { int c=(0x01<<(position-1)); *p_data &= ~c; } } void main() { //unsigned int ch = 'A'; unsigned int ch=3; bit_set(&ch,3,false); // bit_set(&ch,1,true); printf("%d\n",ch); }
原文:http://blog.csdn.net/kai8wei/article/details/44730889