3.2.24. memcpy

Copies a specified number of characters from a source memory area to a destination memory area.

Syntax

char *memcpy (dest, src, count)
char *dest;
char *src;
int count;

where:

dest

A character pointer that specifies the starting address for the destination memory area, to begin writing characters to.

src

A character pointer that specifies the starting address for the source memory area, to begin copying characters from.

count

An integer variable specifying the number of characters (bytes) to be copied, from the source location, to the destination location of memory.

Description

Copies count characters from the source memory area, pointed to by src, and writes this character string to a destination memory area, pointed to by dest.

Return value

char *

A pointer to the destination location that is one byte beyond the last byte written to. This enables continuation of the writing process with perfect alignment of bytes for string concatenation of memory blocks.

Rules

None

Example

This example shows how to use memcpy:

define /R void memoryCpy()
{
  char buff1[37];
  char buff2[37];
  char *posn;
  strcpy(buff1,"1234567890abcdefghijklmnopqrstuvwxyz");
  posn = memcpy(buff2,buff1,20);
  $printf "%s\n",buff2$;
}
.

See Also

Copyright © 2002-2009 ARM Limited. All rights reserved.ARM DUI 0175K
Non-Confidential