inet_addr

Synopsis

unsigned long inet_addr(const char *cp);

Description

Converts an IPv4 address in dotted-decimal notation into a 32‑bit binary representation in network byte order. If the input string is not a valid IPv4 address, the function returns INADDR_NONE (0xFFFFFFFF).

Parameters

Return Value

Remarks

The returned value is suitable for use with socket functions that expect an address in network byte order. For modern applications, consider using InetPton or WSAStringToAddress for more robust parsing.

Example

Enter an IPv4 address to see the inet_addr result:

Related Functions