Bytes On The Wire
#include <stdint.h>
#include <stdio.h>
#include <arpa/inet.h>
int main(void) {
uint32_t v = 0x12345678;
uint32_t n = htonl(v);
unsigned char *p = (unsigned char *)&v;
unsigned char *q = (unsigned char *)&n;
printf("%02x %02x %02x %02x | %02x %02x %02x %02x\n",
p[0], p[1], p[2], p[3], q[0], q[1], q[2], q[3]);
}
What does this print on x86-64?
Sign in to answer questions and track your progress
Sign In