熟悉C语言的位操作

#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;
}


你可能感兴趣的:(c,语言,include,Numbers)