Master the fundamental concepts of network stack fundamentals through this focused micro-challenge.
An IPv4 address like 192.168.1.10 is just a 32-bit number displayed as four 8-bit octets. Every router, firewall rule, and socket API call works with the numeric form; the dotted string exists for humans. For example, 8.8.8.8 packs into four bytes: 08 08 08 08 in hex.
The functions inet_aton and inet_pton in every C network program do exactly what you are about to do: split the string on dots, validate each part fits in 0-255, and pack the result. Common pitfalls include:
010.0.0.1 (some parsers treat leading zeros as octal)192..1.1Get this wrong and you connect to the wrong host or accept malformed input, which has caused real CVEs in address parsers.
This task asks you to implement the first step of every network client: turn a human-readable address into four integers. You will need this same split-and-validate logic when you parse IP headers in later tasks and when you fill sockaddr_in structures by hand. The dotted string is a presentation format; the four integers are what bind(), routing tables, and firewall rules actually store.
Read an IPv4 address in dotted-quad form from stdin (e.g. "192.168.1.10").
Print each octet on its own line as a decimal number:
192 168 1 10
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github