69,371
社区成员
发帖
与我相关
我的任务
分享
#include "Stdio.h"
#include "Conio.h"
void PrintIntByte(int);
int main(void)
{
int a= 'A';int b= 'B';int c= 'C';
PrintIntByte(a);
PrintIntByte(b);
PrintIntByte(c);
getch();
return 0;
}
void PrintIntByte(int aInt)
{
struct IntByte
{
int Part1:16;
int Part2:16;
};
union MyInt
{
int aInt;
struct IntByte aIntByte;
};
union MyInt x;
char s[25];
x.aInt = aInt;
printf("%s\n",itoa(x.aIntByte.Part1,s,2));
printf("%s\n",itoa(x.aIntByte.Part2,s,2));
}
int len, buf[2];
buf[0] = len & 0xff; // 低
buf[1] = len >> 16; // 高
int len,buf[2];
buf[0]=len&0x00ff;//buf[0]存储len的低字节
buf[1]=len>>8;//buf[1]存储len的高字节