So I got my code to prompt the user for a hex number and output a hex number. I'm trying to swap the numbers for them now. ie 0x12 would be displayed 0x21 etc. When I try to >> the number it does the whole number and not the individual characters. How do I get it to swap the individual chars? Any help would be great.
Code:
#include <stdio.h>
unsigned char data (void)
{
unsigned char data;
printf ("\nEnter a hexadecimal value from 0x00 to 0xFF:\n");
scanf ("%hhx", &data);
printf ("In reverse, that is 0x%02\n", data);
return data;
}
char main (void)
{
data ();
return 0;
}