熟悉C语言的位操作

来源:互联网 发布:win10 未识别的网络 编辑:程序博客网 时间:2024/06/18 06:40
#include <stdio.h>int main(){    //HEX Numbers in C    unsigned char myreg = 0x0;    printf("set myreg Enable.\n");    //Setting a BIT in Register    myreg |= (1<<5);    //Testing The Status of a Bit    if (myreg & (1<<5))    {        printf("myreg is Enable\n");        }    else    {        printf("myreg is not Enable\n");        }            printf("set myreg Disable.\n");    //Clearing a BIT in Register    myreg &= ~(1<<5);    //Testing The Status of a Bit    if (myreg & (1<<5))    {        printf("myreg is Enable\n");        }    else    {        printf("myreg is not Enable\n");        }    return 0;}


原创粉丝点击