%MEMCPY

%MEMCPY


%MEMCCPY Index Level %MEMXCPY
Syntax variable = (char*)%MEMCPY( s1, s2, number )
Category BASIC
Type C Function
Description copies the number of characters specified by "number" from memory area "s2" into "s1".

"s1" and "s2" are either FlashBASIC strings or pointers to a character. "variable" is a pointer to "s1". If "s1" is a Pick string, the value returned by this function has no meaning.
Options
See Also c function CFUNCTION %MEMXCPY
Example * Read 1024 bytes from device
* and copy them in a Pick buffer
precision 0
char buffer[1024]
p=(char*)%malloc( 1024 )
n=%read(fd, (char*)p, 1024 )
%memcpy( buffer, p+32, n-32 )

In this example, note the operation on pointers, allowed because of the statement  'precision 0'. This allows reading data from a device, and copy only the portion after a fixed size header (32 bytes in this example).
Warnings If the string contains a segment mark (x'ff'), the data is truncated.
Compatibility D3/Unix
%MEMCCPY Index Level %MEMXCPY