[ Bottom of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]

Technical Reference: Base Operating System and Extensions, Volume 1

memccpy, memchr, memcmp, memcpy, memset or memmove Subroutine

Purpose

Performs memory operations.

Library

Standard C Library (libc.a)

Syntax

#include <memory.h>

void *memccpy (Target, Source, C, N)
void *Target;
const void *Source;
int C;
size_t N;


void *memchr ( S, C, N)
const void *S;
int C;
size_t N;

int memcmp (Target, Source, N)
const void *Target, *Source;
size_t N;

void *memcpy (Target, Source, N)
void *Target;
const void *Source;
size_t N;

void *memset (S, C, N)
void *S;
int C;
size_t N;

void *memmove (Target, Source, N)
void *Source;
const void *Target;
size_t N;

Description

The memory subroutines operate on memory areas. A memory area is an array of characters bounded by a count. The memory subroutines do not check for the overflow of any receiving memory area. All of the memory subroutines are declared in the memory.h file.

The memccpy subroutine copies characters from the memory area specified by the Source parameter into the memory area specified by the Target parameter. The memccpy subroutine stops after the first character specified by the C parameter (converted to the unsigned char data type) is copied, or after N characters are copied, whichever comes first. If copying takes place between objects that overlap, the behavior is undefined.

The memcmp subroutine compares the first N characters as the unsigned char data type in the memory area specified by the Target parameter to the first N characters as the unsigned char data type in the memory area specified by the Source parameter.

The memcpy subroutine copies N characters from the memory area specified by the Source parameter to the area specified by the Target parameter and then returns the value of the Target parameter.

The memset subroutine sets the first N characters in the memory area specified by the S parameter to the value of character C and then returns the value of the S parameter.

Like the memcpy subroutine, the memmove subroutine copies N characters from the memory area specified by the Source parameter to the area specified by the Target parameter. However, if the areas of the Source and Target parameters overlap, the move is performed nondestructively, proceeding from right to left.

The memccpy subroutine is not in the ANSI C library.

Parameters

Target Points to the start of a memory area.
Source Points to the start of a memory area.
C Specifies a character to search.
N Specifies the number of characters to search.
S Points to the start of a memory area.

Return Values

The memccpy subroutine returns a pointer to character C after it is copied into the area specified by the Target parameter, or a null pointer if the C character is not found in the first N characters of the area specified by the Source parameter.

The memchr subroutine returns a pointer to the first occurrence of the C character in the first N characters of the memory area specified by the S parameter, or a null pointer if the C character is not found.

The memcmp subroutine returns the following values:

Less than 0 If the value of the Target parameter is less than the values of the Source parameter.
Equal to 0 If the value of the Target parameter equals the value of the Source parameter.
Greater than 0 If the value of the Target parameter is greater than the value of the Source parameter.

Related Information

The swab subroutine.

Subroutines Overview in AIX 5L Version 5.2 General Programming Concepts: Writing and Debugging Programs.

[ Top of Page | Previous Page | Next Page | Contents | Index | Library Home | Legal | Search ]