I am trying to reverse the unsigned integer by using the '«' and '»', and bitwise 'AND' and 'OR' (& and |), but can't figure out how to do this.
What I already have;
int main(int argc, char** argv) {
unsigned int getal;
scanf("%i", &getal);
printf("%X\n", getal);
return 0;
}
User input: 0xaabbccdd, output now: AABBCCDD, what it should output DDCCBBAA
I also tried;
int main(int argc, char** argv) {
unsigned int getal;
unsigned int x;
scanf("%i", &getal);
int i;
for (i = 0; i < 32; ++i) {
getal <<= 1;
getal |= (x & 1);
x >>= 1;
printf("%X\n", getal);
}
return 0;
}
but the result was completely different.