118. Program to swap 1st and 4th byte - 2nd and 3rd byte using character pointer
#include<stdio.h>
int
i = 0xAABBCCDD;
char
*a,*b,*c,*d;
void
main()
{
printf("Program to swap 1st and
4th byte - 2nd and 3rd byte using character pointer\n");
printf("Before swaping i =
%X\n",i);
a=(char *)&i;
b=a+1;
c=b+1;
d=c+1;
*a=*a^*d;
*d=*a^*d;
*a=*a^*d;
*b=*b^*c;
*c=*b^*c;
*b=*b^*c;
printf("%X\n ",i);
}
Comments
Post a Comment