basic.%memcpy
Copies memory.
Syntax
variable=(char*)%memcpy(s1, s2, number )
Description
copies the number of characters specified by 'number' from memory area 's2' into 's1'.
's1' and 's2' are either Pick/BASIC 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.
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).
See Also
User Comments
What do you think?
Share your experience or ask a question by using the form below.
Login to leave your comments.
