MEMORY(3C)
NAME
memccpy, memchr, memcmp, memcpy, memmove, memset − memory operations
SYNOPSIS
#include <string.h>
void ∗memccpy (s1, s2, c, n)
void ∗s1;
const void ∗s2;
int c;
size_t n;
void ∗memchr (s, c, n)
const void ∗s;
int c;
size_t n;
int memcmp (s1, s2, n)
const void ∗s1, ∗s2;
size_t n;
void ∗memcpy (s1, s2, n)
void ∗s1;
const void ∗s2;
size_t n;
void ∗memmove (s1, s2, n)
void ∗s1;
const void ∗s2;
size_t n;
void ∗memset (s, c, n)
void ∗s;
int c;
size_t n;
DESCRIPTION
These functions operate as efficiently as possible on memory areas (arrays of characters bounded by a count, not terminated by a null character). They do not check for the overflow of any receiving memory area.
Definitions for all these functions, the type size_t, and the constant NULL are provided in the <string.h> header.
Memccpy copies characters from the object pointed to by s2 into the object pointed to by s1, stopping after the first occurrence of character c has been copied, or after n characters have been copied, whichever comes first. If copying takes place between objects that overlap, the behavior is undefined. It returns a pointer to the character after the copy of c in s1, or a NULL pointer if c was not found in the first n characters of s2.
Memchr locates the first occurrence of c (converted to an unsigned char) in the initial n characters (each interpreted as unsigned char) of the object pointed to by s. It returns a pointer to the located character, or a NULL pointer if the character does not occur in the object.
Memcmp compares the first n characters of the object pointed to by s1 to the first n characters of the object pointed to by s2. It returns an integer greater than, equal to, or less than zero, according as the object pointed to by s1 is greater than, equal to, or less than the object pointed to by s2. The sign of a nonzero return value is determined by the sign of the difference between the values of the first pair of characters (both interpreted as unsigned char) that differ in the objects being compared.
Memcpy copies n characters from the object pointed to by s2 into the object pointed to by s1. If copying takes place between objects that overlap, the behavior is undefined. It returns the value of s1.
Memmove copies n characters from the object pointed to by s2 into the object pointed to by s1. Copying takes place as if the n characters from the object pointed to by s2 are first copied into a temporary array of n characters that does not overlap the objects pointed to by s1 and s2, and then the n characters from the temporary array are copied into the object pointed to by s1. It returns the value of s1.
Memset copies the value of c (converted to an unsigned char) into each of the first n characters of the object pointed to by s. It returns the value of s.
International Code Set Support
These functions support only single-byte character code sets.
WARNING
These functions were previously defined in <memory.h>.
SEE ALSO
STANDARDS CONFORMANCE
memccpy: SVID2, XPG2, XPG3
memchr: SVID2, XPG2, XPG3, ANSI C
memcmp: SVID2, XPG2, XPG3, ANSI C
memcpy: SVID2, XPG2, XPG3, ANSI C
memmove: ANSI C
memset: SVID2, XPG2, XPG3, ANSI C
Hewlett-Packard Company — HP-UX Release 7.0: Sept 1989