udi_strcmp, udi_strncmp, udi_memcmp


String/memory comparison

SYNOPSIS

#include <udi.h>
udi_sbit8_t udi_strcmp (

	const char *s1,

	const char *s2 );
 
udi_sbit8_t udi_strncmp (

	const char *s1,

	const char *s2,

	udi_size_t n );
 
udi_sbit8_t udi_memcmp (

	const void *s1,

	const void *s2,

	udi_size_t n );
 

ARGUMENTS s1 is a pointer to the first character string or memory area.

s2 is a pointer to the second character string or memory area.

n is the maximum size to be compared (in bytes).

DESCRIPTION The udi_strcmp and udi_strncmp functions are used to compare the contents of two null-terminated character strings. The strings are compared on a byte-by-byte basis and a comparison value is returned when the first differing character or the end of the strings is reached.

For the udi_strncmp function, comparison halts after comparing n characters unless the end of either string has already been reached. If both strings are identical throughout the first n characters, the udi_strncmp function return value indicates that the strings are equal, regardless of any remaining content.

The udi_memcmp function operates in a similar manner as udi_strncmp except that null characters do not terminate the comparison, which will always continue until the specified n bytes have been compared or a difference has been reached.

RETURN VALUES These functions return an integer value less than, equal to, or greater than zero if s1 (or the first n bytes thereof) is lexicographically less than, equal, to, or greater than s2. This comparison is made by comparing each unsigned byte value until there is a mismatch or all bytes compare equal.


UDI Core Specification Contents