# %memcopy() function

The %memcopy() function copies characters
from the memory area specified by *s2* into *s1*, stopping after the first occurrence of the character
designated by *character* has been copied, or after
the number of characters specified by length have been copied, whichever
comes first.

## Syntax

```
var = (char*)%memcopy(s1, s2, (char) character, length)
```

## Parameter(s)

| var | Pointer to the character after the copy of character in s1 or a null pointer if c is found in the first length characters of s2. |
| --- | --- |
| s1 | Can be a FlashBASIC string or a pointer to a character. If s1 is a D3 string, the value returned by this function, except null, has no meaning. |
| s2 | Can be a FlashBASIC string or a pointer to a character. |
| character | Character to copy. |
| length | Number of characters to copy. |
Note: If the source string contains a segment mark (x’ff’),
the string is truncated.

## See also

- [%memxcpy() function](https://d3codex.com/pickbasic-flashbasic/percent-memxcpy-function/)
- [FlashBASIC C functions overview](https://d3codex.com/pickbasic-flashbasic/flashbasic-c-functions-overview/)
- [cfunction statement](https://d3codex.com/pickbasic-flashbasic/cfunction-statement/)

---
Source: https://d3codex.com/pickbasic-flashbasic/percent-memcopy-function/ - part of the D3Codex reference.
