MEMORY(3C) SysV MEMORY(3C)
NAME
memory: 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.
memccpy copies characters from memory area s2 into s1, stopping after the
first occurrence of character c (converted to an unsigned char) has been
copied, or after n characters have been copied, whichever comes first.
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. If
copying takes place between objects that overlap, the behavior is
undefined.
memchr returns a pointer to the first occurrence of character c
(converted to an unsigned char) in the first n characters (interpreted as
unsigned char) of memory area s, or a NULL pointer if c does not occur.
memcmp compares its arguments, looking at the first n characters
(interpreted as unsigned char) only, and returns an integer less than,
equal to, or greater than 0, according as s1 is lexicographically less
than, equal to, or greater than s2.
memcpy copies n characters from memory area s2 to s1. It returns s1. If
copying takes place between objects that overlap, the behavior is
undefined.
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. memmove returns the value of s1.
memset sets the first n characters in memory area s to the value of
character c (converted to an unsigned char). It returns s.
SEE ALSO
<string.h>, cc(1).
NOTES
To be compatible with traditional C usage, make memchr, memcpy, and
memset return type pointer-to-character by compiling your program with
the
-A nansi
option (see cc(1)) and inserting the directive
#define _CLASSIC_TYPES
before any #include directives.
CAVEATS
memcmp is implemented by using the most natural character comparison on
the machine. Thus the sign of the value returned when one of the
characters has its high order bit set is not the same in all
implementations and should not be relied upon.
Character movement is performed differently in different implementations.
Thus overlapping moves may yield surprises.