Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

string(3)

swab(3)

memccpy(3)  —  Subroutines

OSF

NAME

memccpy, memchr, memcmp, memcpy, memset, memmove −  Performs memory operations

LIBRARY

Standard C Library  (libc.a)

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) ;

PARAMETERS

sPoints to the location of a string. 

s1Points to the location of a destination string. 

s2Points to the location of a source string. 

cSpecifies a character for which to search. 

nSpecifies the number of characters to search. 

DESCRIPTION

The memccpy(), memchr(), memcmp(), memcpy(), memset(), and memmove() functions operate on strings in memory areas. A memory area is a group of contiguous characters bound by a count and not terminated by a null character. These memory functions do not check for overflow of the receiving memory area. All of these memory functions are declared in the string.h header file. 

The memccpy() function sequentially copies characters from the location pointed to by the s1 parameter into the location pointed to by the s2 parameter until one of the following occurs:

       •The character specified by the c parameter (which is converted to an unsigned int) is encountered. 

       •The number of characters specified by the n parameter have been copied to the string at location s1. 

A pointer to character c in the string pointed to by s1 is returned. When character c is not encountered after n characters have been copied to the string at location s1, a null pointer is returned. 

The memchr() function sequentially searches the string at the location pointed to by the s parameter until one of the following occurs:

       •The character specified by the c parameter (which is conveted to an unsigned int) is encountered. 

       •The number of characters specified by the n parameter have been copied to the string at location s. 

A pointer to character c in the string pointed to by s is returned. When character c is not encountered after n characters have been copied to the string at location s, a null pointer is returned. 

The memcmp() function compares the first n characters (which are converted to unsigned char) of the string pointed to by the s1 parameter with the first n characters (also interpreted as unsigned char) of the string pointed to by the s2 parameter. 

The memcmp() function uses native character comparison, which may have signed values on some machines. This function returns one of the following values:

Less than 0When s1 is less than s2

Equal to 0When s1 is equal to s2

Greater than 0
When s1 is greater than s2

The memcpy() function copies n characters from the string pointed to by the s2 parameter into the location pointed to by the s1 parameter.  When copying overlapping strings, the behavior of this function is unreliable. 

The memset() function copies the value of the character specified by the c parameter (which is converted to an unsigned char) into each of the first n locations of the string pointed to by the s parameter. 

The memmove() function copies n characters from the string at the location pointed to by the s2 parameter to the string at the location pointed to by the s1 parameter.  Copying takes place as though the n number of characters from string s2 are first copied into a temporary location having n bytes that do not overlap either of the strings pointed to by s1 and s2. Then, n number of characters from the temporary location are copied to the string pointed to by s1. Consequently, this operation is nondestructive and proceeds from left to right. 

NOTES

AES Support Level:
Full use (memchr(), memcmp(), memcpy(), memmove(), memset()) Trial use (memccpy())

RETURN VALUES

The memccpy() function returns a pointer to the character following the character specified by the c parameter in the string pointed to by the s1 parameter. When character c is not found after the number of characters specified by the n parameter are scanned, a null pointer is returned. 

The memccpy() function returns a pointer to the character specified by the c parameter. When character c does not occur after n characters in the string pointed to by the s parameter are scanned, a null pointer is returned. 

The memcmp() function returns a value greater than, equal to, or less than 0 (zero), accordingly as the string pointed to by the s1 parameter has a value greater than, equal to, or less than the string pointed to by the s2 parameter. 

The memcpy() and memmove() functions return the string pointed to by the s1 parameter. 

The memset() function returns the string pointed to by the s parameter. 

RELATED INFORMATION

Functions: string(3), swab(3)

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026