I was just experimenting and I tried out two printf()s.
unsigned char a = 1;
a = ~a;
printf("----> %x %x %x %x", ~a, a, ~a, ++a);
This one gave the output
----> ffffff00 ff ffffff00 ff
Next one was
unsigned char a = 1;
printf("----> %x %x %x %x", ~a, a, ~a, ++a);
This one gave the output
----> fffffffd 2 fffffffd 2
Now, I know what '++' does and '~' does. I also know that the sequence of operation inside printf is from the right.
But could some one explain the difference in the number of bytes printed? A total explanation of output would be helpful of course, but I am more interested in the number of bytes and the difference in both cases [especially in the printf a and ~a parts].
EDIT:
OK, looks like the ++ part and my mistake of "I also know that the sequence of operation inside printf is from the right" has prompted every post other than the answer I was hopefully looking for. So may be the way I asked was wrong.
I will try again,
unsigned char a = ~1;
a = ~a;
printf("----> %x", a);
OUTPUT: ----> 1
unsigned char a = ~1;
printf("----> %x", ~a);
OUTPUT: ----> ffffff01
Why this difference?