简单的位运算就可以了
#include
void printBin(int num){
int i,k=31;
for(i=0;i<32;i++){
printf("%d",(num>>k)&1);//移位并输出
k--;
}
printf("\n");
}
int main(int argc, char* argv[])
{
int num;
printf("Please input a number, I will tell you what it really is:");
scanf("%d",&num);
printf("It is binary display is:");
printBin(num);
return 0;
}