Formatting 16 bytes in hex
I have this program and it appears the %016X formatting spec is not working right. Am I doing something wrong?
Code:
#include <stdio.h>
#include <string.h>
int main (void) {
char a[4] ;
char b[4] ;
char c[9] ;
unsigned int int1 = 1 ;
unsigned int int2 = 2 ;
memcpy(a, &int1, 4) ;
memcpy(b, &int2, 4) ;
memcpy(c,a,4) ;
memcpy(c+4,b,4) ;
c[8] = 0 ;
printf("a = %08X\n", *a) ;
printf("b = %08X\n", *b );
printf("c = %016X\n", *c ); // <-- why only 8 bytes?
printf("c+0(4) = %08X\n", *c ) ;
printf("c+4(4) = %08X\n", *(c+4) ) ;
return 0;
}
This produces:
Code:
a = 00000001
b = 00000002
c = 0000000000000001
c+0(4) = 00000001
c+4(4) = 00000002
Is 8 bytes the max %x can handle? I'm expecting 0000000100000002
Todd