memcmp(3)

memcmp3

Compare byte string

Usage

#include <string.h>

int

memcmp(const void *s1, const void *s2, size_t n);

Library

Standard C Library (libc, -lc)

Overview

The memcmp() function compares byte string s1 against byte string s2. Both strings are assumed to be n bytes long.

Return values

The memcmp() function returns zero if the two strings are identical, otherwise returns the difference between the first two differing bytes (treated as unsigned char values, so that ‘\200’ is greater than ‘\0’, for example). Zero-length strings are always identical. This behavior is not required by C and portable code should only depend on the sign of the returned value.

Releases

163 releases since Mac OS X 10.0; the text changed 4 times.

  1. 10.0–10.1.5
  2. 10.2–10.4.11
  3. 10.5–10.6.8
  4. 10.7–10.11.6
  5. 10.12–26.5

Standards

The memcmp() function conforms to ISO/IEC 9899:1990 (“ISO C90”).

From Libc 1752.120.2 in macOS 26.5. Parsed by carta from the page's mdoc source.