---
name: "fmt_ip4"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/fmt_ip4"
---

# fmt\_ip4(3)

write a formatted ASCII representation of an IPv4 number

## NAME

fmt\_ip4 - write a formatted ASCII representation of an IPv4 number

## SYNTAX

**#include \<libowfat/ip4.h\>**

unsigned int **fmt\_ip4**(char \**dest*,const char *ip*\[4\]);

## DESCRIPTION

fmt\_ip4 formats an IPv4 number in dotted-decimal ASCII representation from *ip* and writes the result into *dest*. It returns the number of bytes written.

If *dest* equals FMT\_LEN (i.e. is zero), fmt\_ip4 returns the number of bytes it would have written.

fmt\_ip4 does not append \\0.

For convenience, ip4.h defines the integer IP4\_FMT to be big enough to contain every possible fmt\_ip4 output plus \\0.

## EXAMPLE

\#include \<libowfat/ip4.h\>

  char buf\[IP4\_FMT\];\
   char ip\[4\];\
   buf\[fmt\_ip4(buf,ip)\]=0;

## SEE ALSO

[scan\_ip4(3)](/scan_ip4/3.md), [fmt\_ip6(3)](/fmt_ip6/3.md), [inet\_ntop(3)](/inet_ntop/3.md)
