---
name: "strverscmp"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/strverscmp"
---

# strverscmp(3)

compare strings according to natural order

## NAME

**strverscmp** – compare strings according to natural order

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<string.h\>**

*int*\

**strverscmp**(*const char \*s1*, *const char \*s2*);

## DESCRIPTION

The **strverscmp**() function compares the null-terminated strings *s1* and *s2* according to their natural order and returns an integer greater than, equal to, or less than 0, depending on whether *s1* is greater than, equal to, or less than *s2*.

More specifically, this natural order is found by iterating over both strings until a difference is found. If the difference is between non-decimal characters, **strverscmp**() acts like [strcmp(3)](/strcmp/3.md) (thus, the ordering would be "a", "b", "train"). If a decimal digit is found, the whole number is read and compared (thus, the ordering would be "9", "10", "420" which is different to lexicographic order, what [strcmp(3)](/strcmp/3.md) would have done). Numbers with leading zeroes are interpreted as fractional parts (even without a decimal point), and numbers with more leading zeroes are placed before numbers with fewer leading zeroes (thus, the ordering would be "000", "00", "01", "010", "09", "0", "1", "9", "10").

## SEE ALSO

[strcmp(3)](/strcmp/3.md), [versionsort(3)](/versionsort/3.md)

## STANDARDS

The **strverscmp**() function is a GNU extension and conforms to no standard.

## HISTORY

The **strverscmp**() function was added in FreeBSD 13.2.
