/* ******************************** * 将某一个char中的第local位置为1 * *********************************/ int SetBit(unsigned char *Des, int local) { const static int markbuf[ ] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 }; if ( local > 8 ) { return 0; } Des[ 0 ] |= markbuf[ local - 1 ]; /* local对应数组第local-1 */ return 1; } /* ******************************** * 判断char中的第local位置是否为1 * *********************************/ int CompareBit(unsigned char *Des, int local) { const static int markbuf[ ] = { 0x1, 0x2, 0x4, 0x8, 0x10, 0x20, 0x40, 0x80 }; if ( local > 8 ) { return 0; } return (Des[ 0 ] & markbuf[ local+1 ]) == markbuf[ local+1 ]; }