/* testbit.c*/
#include
#define BIT(x) (1<typedef unsigned long int DWORD;
DWORD SetBit(DWORD dwNum, int n);
int main()
{
DWORD dwN = 1;
int n = 0;
for ( n = 0; n < 32; n++ )
printf("%d\n", SetBit(dwN, n));
return 0;
}
DWORD SetBit(DWORD dwNum, int n)
{
return (dwNum | BIT(n));
}
函数SetBit将一个DWORD值的第n位置为1.注意,n是从0开始的,一直到31(包括31)。
阅读(1643) | 评论(0) | 转发(0) |