IntToBinaryString

void IntToBinaryString(int devisor,char* pBinStr)
{
    int i;
    int remainder;    
    for(i=0;i<8;i++)
    {
        remainder=devisor & 0x01;
        devisor=devisor >> 1;        
        pBinStr[i]=(remainder == 1)?'1':'0';
    }    
    pBinStr[8]='\0';
}

void main()
{
    int x=0xc3;
    char action[9];
    IntToBinaryString(x,action);
    printf("%s\n",action);
}
/*
11000011
Press any key to continue
*/

 

posted @ 2017-02-24 09:37  sky20080101  阅读(142)  评论(0编辑  收藏  举报