Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ mem(lib) — Sprite KS.390

Media Vault

Software Library

Restoration Projects

Artifacts Sought

mem  —  C Library Procedures

NAME

memchr, memcmp, memcpy, memset − Operations on byte arrays

SYNOPSIS

#include <string.h>
 char ∗
memchr(s, c, n)
 int
memcmp(s, s2, n)
 char ∗
memcpy(dest, source, n)
 char ∗
memset(dest, c, n)

ARGUMENTS

char ∗s   (in) Pointer to array of characters. 

char ∗source   (in) Pointer to array of characters to copy. 

char ∗dest   (out) Pointer to array of characters to modify. 

int c   (in) Value to search for (memchr), or value to set to (memset). 

int n   (in) Count of number of characters to test, copy, or set. 
 

DESCRIPTION

These procedures manipulate memory as counted arrays of bytes. 

The memchr procedure searches for the first occurrence of c in the n bytes starting at s, and returns the address of the first such occurrence.  If the value c is not found, then NULL is returned. 

Memcmp compares two arrays of bytes, s and s2, in order, until a difference is found or n bytes have been compared.  It returns a value greater than zero if, in the first differing byte, the value s is greater than the value in s2.  If the value in s is less than the value in s2, then a value less than zero is returned.  If the two arrays are identical in their first n bytes, then zero is returned.  Signed character comparison is used. 

Memcpy copies n bytes from source to dest and returns dest as its result. 

Memset stores the value c in each of the n bytes starting at dest, and returns dest as its result. 
 

KEYWORDS

characters, copy, memory, set, test

Sprite version 1.0  —  February 09, 1989

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