---
name: "strdiff"
section: "3pub"
platform: "linux"
package: "publib-dev"
version: "0.40-4"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/strdiff"
---

# strdiff(3pub)

locate first difference between two strings

## NAME

strdiff - locate first difference between two strings

## SYNOPSIS

```
#include <publib.h>
size_t strdiff(const char *str1, const char *str2);
```

## DESCRIPTION

*strdiff* finds the first character from the beginning that is different in the two strings *str1* and *str2*. The terminating zero characters are considered different.

## RETURN VALUE

*strdiff* returns a the offset of the first pair of differring characters (or the offset of the first zero character it finds).

## SEE ALSO

publib(3), [string(3)](/string/3.md), [strcmp(3)](/strcmp/3.md)

## AUTHOR

Lars Wirzenius (lars.wirzenius@helsinki.fi)
