#include <bitset> #include<iostream> void show_bytes(unsigned char *start,int len) { std::bitset<8> aByte; for (int i =0;i<len;i++) { aByte = start[i]; for (int j=0;j<8;j++) { std::cout<<aByte[j]; } std::cout<<std::endl; } } void main() { int i = 2; show_bytes((unsigned char*)&i,sizeof(i)); std::cout<<"double d=3.0"<<std::endl; double d=3.0; show_bytes((unsigned char*)&d,sizeof(d)); }
时间: 2024-10-12 08:32:23