#include
#include
typedef unsigned char *byte_pointer;
void show_bytes(unsigned output)
{
int i,temp;
int len=0;
char index[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
char *res=(char*)malloc(30);
printf("0x");
while (output!=0)
{
*res++=index[output%16];
len++;
output/=16;
}
res--;
for (i=len-1;i>=0;i--)
{
printf("%c",*res--);
}
printf("\n");
}
unsigned put_byte (unsigned x, unsigned char b, int i)
{
unsigned *px;
unsigned char *p;
px=&x;
p=(unsigned char *)px;
*(p++)=b;
return x;
}
int main()
{
unsigned input=0x12345678;
unsigned output=put_byte (input, 0xAB, 1);
printf("0x%x\n",output);
show_bytes(output);
return 0;
}