3.2.25. memset

Fills a specified area of memory with a character.

Syntax

char *memset (dest, byte_value, count)
char *dest;
char byte_value;
int count;

where:

dest

A character pointer to the memory location where the memset macro is to write a string of repeating characters.

byte_value

A character variable used to specify the number of times that a character is written consecutively, beginning at the *dest address.

count

An integer variable used to specify the number of times a particular character is to be written consecutively, beginning with the byte whose address is *dest.

Description

This macro writes a character in memory multiple times. The memset macro writes the character byte_value into the contents of the first count bytes in memory, beginning with the byte pointed to by dest. For example, write character 'X' consecutively, one hundred times, beginning at address 0x8f51fff4.

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 memset:

define /R void memorySet()
{
  char buff[37];
  char *posn;
  posn = memset(buff,'@',20);
  $printf "%s\n",buff$;
}
.

See Also

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