memccpy, memchr, memcmp, memcpy, memset, bcopy
Purpose
Performs memory operations.
Library
Standard C Library (libc.a)
Syntax
#include <memory.h>
char *memccpy (target, source, c, n) char *memcpy (target, source, n)
char *target, *source; char *target, *source;
int c, n; int n;
char *memchr (s, c, n) char *memset (s, c, n)
char *s; char *s;
int c, n; int c, n;
int memcmp (target, source, n) char *bcopy (source, target, n)
char *target, *source; char *source, *target;
int n; int n;
Description
The memory subroutines operate on memory areas. A memory
area is an array of characters bounded by a count, and
not terminated by a null character. The memory subrou-
tines do not check for the overflow of any receiving
memory area. All of the memory subroutines are declared
in the memory.h header file.
The memccpy subroutine copies characters from memory area
source into memory area target. The memccpy subroutine
stops after the first character c is copied, or after n
characters have been copied, whichever comes first.
memccpy returns a pointer to the character after c is
copied into target, or a NULL pointer if c is not found
in the first n characters of source.
The memchr subroutine returns a pointer to the first
occurrence of character c in the first n characters of
memory area s, or a NULL pointer if c does not occur.
The memcmp subroutine lexicographically compares the
first n characters in memory area target to the first n
characters in memory area source. memcmp uses native
character comparison, which may be signed on some
machines. The memcmp subroutine returns the following
values:
Less than 0 If target is less than source
Equal to 0 If target is equal to source
Greater than 0 If target is greater than source.
The memcpy subroutine copies n characters from memory
area source to area target and returns target.
The memset subroutine sets the first n characters in
memory area s to the value of character c and returns s.
Like the memcpy subroutine, the bcopy subroutine copies n
characters from memory area source to area target. The
order of the parameters is reversed for bcopy, with the
source being specified first. This subroutine has no
return values.
Warning: Character movement is performed differently in
different implementations of these subroutines; there-
fore, overlapping moves may yield unexpected results.
Related Information
In this book: "string" and "swab."