# %memxcpy() function

The %memxcpy() function copies a specified
 number of characters from memory area *s2* into *s1*, and converts each input character into two ASCII hexadecimal
characters 0 through 9 and A through F.

## Syntax

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

## Parameter(s)

| var | Pointer after the last converted character in s2. |
| --- | --- |
| s1 | Can be a FlashBASIC string or a pointer to a character. |
| s2 | Can be a FlashBASIC string or a pointer to a character. If s2 is a D3 string, the value returned by this function has no meaning. |
| length | Number of bytes to copy. |

## Example(s)

```
* Obtain memory workspace
ptr=(char*)%malloc(2048)
* Read from file
n=%read(fd, (char*)ptr, 1024)
* Convert the binary data into hexadecimal ASCII
char buffer[2048]
%memxcpy(buffer, (char*)ptr, n*2)
```

## See also

- [%memcopy() function](https://d3codex.com/pickbasic-flashbasic/percent-memcopy-function/)
- [%memcpy() function](https://d3codex.com/pickbasic-flashbasic/percent-memcpy-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-memxcpy-function/ - part of the D3Codex reference.
