networking · intermediate · ~15 min
Read a big-endian field at a fixed offset.
A DNS message header is 12 bytes; the question count QDCOUNT is the big-endian 16-bit value at offset 4. Implement int dns_qdcount(const unsigned char *hdr) returning it.
int dns_qdcount(const unsigned char *hdr) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.