memory(3C)
NAME
memccpy(), memchr(), memcmp(), memcpy(), memmove(), memset(), bcopy(), bcmp(), bzero(), ffs() − memory operations
SYNOPSIS
#include <string.h>
void *memccpy(void *s1, const void *s2, int c, size_t n);
void *memchr(const void *s, int c, size_t n);
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *s1, const void *s2, size_t n);
void *memmove(void *s1, const void *s2, size_t n);
void *memset(void *s, int c, size_t n);
#include <strings.h>
int bcmp(const char *s1, const char *s2, int n);
void bcopy(const char *s1, char *s2, int n);
void bzero(char *s, int n);
int ffs(int i);
Remarks:
bcmp(), bcopy(), bzero(), ffs(), and <strings.h> are provided solely for portability of BSD applications, and are not recommended for new applications where portability is important. For portable applications, use memcmp(), memmove(), and memset(), respectively. ffs() has no portable equivalent.
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 file.
memccpy() Copy 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. memccpy() 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() Locate 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. memchr() returns a pointer to the located character, or a NULL pointer if the character does not occur in the object.
memcmp() Compare the first n characters of the object pointed to by s1 to the first n characters of the object pointed to by s2. memcmp() returns an integer greater than, equal to, or less than zero, according to whether the object pointed to by s1 is greater than, equal to, or less than the object pointed to by s2. The sign of a non-zero 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() Copy 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. memcpy() returns the value of s1.
memmove() Copy 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() Copy the value of c (converted to an unsigned char) into each of the first n bytes of the object pointed to by s. memset() returns the value of s.
bcopy() copies n bytes from the area pointed to by s1 to the area pointed to by s2.
bcmp() Compare the first n bytes of the area pointed to by s1 with the area pointed to by s2. bcopy() returns zero if they are identical; non-zero otherwise. Both areas are assumed to be n bytes in length.
bzero() Clear n bytes in the area pointed to by s by setting them to zero.
ffs() Find the first bit set (beginning with the least significant bit) and return the index of that bit. Bits are numbered starting at one. A return value of 0 indicates that i is zero.
International Code Set Support
These functions support only single-byte character code sets.
WARNING
The functions defined in <string.h> were previously defined in <memory.h>.
SEE ALSO
STANDARDS CONFORMANCE
memccpy(): AES, SVID2, XPG2, XPG3, XPG4
memchr(): AES, SVID2, XPG2, XPG3, XPG4, ANSI C
memcmp(): AES, SVID2, XPG2, XPG3, XPG4, ANSI C
memcpy(): AES, SVID2, XPG2, XPG3, XPG4, ANSI C
memmove(): AES, XPG4, ANSI C
memset(): AES, SVID2, XPG2, XPG3, XPG4, ANSI C
Hewlett-Packard Company — HP-UX Release 9.0: August 1992