B
buzzdee
hi,
i just wanted to print out
some unsigned long int values in hexadecimal,
printing out one value works, but not byte by byte.
anybody has a suggestinon what my problem is?
this is my program:
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <stdio.h>
int main (void) {
unsigned long testint = 6070;
unsigned long bigend = htonl(testint);
char *le = (char *) &testint;
char *be = (char *) &bigend;
printf("HO: %08X\n", testint);
printf("NO: %08X\n", bigend);
printf("HO: %02X %02X %02X %02X\n", le[0], le[1], le[2], le[3]);
printf("NO: %02X %02X %02X %02X\n", be[0], be[1], be[2], be[3]);
}
and this is my output:
$ ./test
HO: 000017B6
NO: B6170000
HO: FFFFFFB6 17 00 00
NO: 00 00 17 FFFFFFB6
anybody can tell me why i have that FFFFFFB6 Values in the output wiht
%02X ?
buzz
i just wanted to print out
some unsigned long int values in hexadecimal,
printing out one value works, but not byte by byte.
anybody has a suggestinon what my problem is?
this is my program:
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <stdio.h>
int main (void) {
unsigned long testint = 6070;
unsigned long bigend = htonl(testint);
char *le = (char *) &testint;
char *be = (char *) &bigend;
printf("HO: %08X\n", testint);
printf("NO: %08X\n", bigend);
printf("HO: %02X %02X %02X %02X\n", le[0], le[1], le[2], le[3]);
printf("NO: %02X %02X %02X %02X\n", be[0], be[1], be[2], be[3]);
}
and this is my output:
$ ./test
HO: 000017B6
NO: B6170000
HO: FFFFFFB6 17 00 00
NO: 00 00 17 FFFFFFB6
anybody can tell me why i have that FFFFFFB6 Values in the output wiht
%02X ?
buzz