networking · beginner · ~15 min
Serialise a port in network byte order.
Implement void port_to_be(int port, unsigned char *out) writing port as two big-endian bytes into out[0] (high) and out[1] (low).
void port_to_be(int port, unsigned char *out) {
/* TODO */
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.