Museum

Home

Lab Overview

Retrotechnology Articles

⇒ Online Manual

Media Vault

Software Library

Restoration Projects

Artifacts Sought

memory(3)

Name

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

Syntax

#include <string.h>

void *memccpy (s1, s2, c, n)
void *s1, *s2;
int c;
size_t n;

void *memchr (s, c, n)
void *s;
int c;
size_t n;

int memcmp (s1, s2, n)
void *s1, *s2;
size_t n;

void *memcpy (s1, s2, n)
void *s1, *s2;
size_t n;

void *memset (s, c, n)
void *s;
int c;
size_t n;

void *memmove (s1, s2, n)
void *s1, *s2;
size_t n;

Description

These functions operate efficiently 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. 

The memccpy subroutine copies characters from memory area s2 into s1, stopping after the first occurrence of character c 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.

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 compares its arguments, looking at the first n characters 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.

The memcpy subroutine copies n characters from memory area s2 to s1. It returns s1.

The memmove subroutine is like memcpy , except that if s1 and s2 specify overlapping areas, memmove works as if an intermediate buffer is used.

The memset subroutine sets the first n characters in memory area s to the value of character c. It returns s.

Restrictions

The memcmp subroutine uses native character comparison, which is signed on PDP−11s, unsigned on other machines.

Character movement is performed differently in different implementations of memccpy and memcpy. Thus overlapping moves, using these subroutines, may yield unpredictable results.

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