This wiki is out of date, use the continuation of this wiki instead

Memcopy

From FenixWiki

(Difference between revisions)
Jump to: navigation, search
Revision as of 03:12, 29 April 2007 (edit)
Sandman (Talk | contribs)

← Previous diff
Revision as of 01:08, 30 April 2007 (edit) (undo)
Sandman (Talk | contribs)
m (Definition)
Next diff →
Line 3: Line 3:
==Definition== ==Definition==
-'''INT''' memcopy ( <'''VOID POINTER''' destination> , <'''VOID POINTER''' origin> , '''INT''' size )+'''INT''' memcopy ( <'''VOID POINTER''' destination> , <'''VOID POINTER''' origin> , <'''INT''' size> )
Copies a certain number of [[byte]]s from one point in [[memory]] to another. Copies a certain number of [[byte]]s from one point in [[memory]] to another.

Revision as of 01:08, 30 April 2007


Contents

Definition

INT memcopy ( <VOID POINTER destination> , <VOID POINTER origin> , <INT size> )

Copies a certain number of bytes from one point in memory to another.

Parameters

VOID POINTER destination - Pointer to the first byte of the destination.
VOID POINTER origin - Pointer to the first byte of the origin.
INT size - The size of the to be copied memory in bytes.

Returns

INT : true

Example

Program example;
Const
    elements = 10;
End
Private
    byte bytearray[elements*2];
    byte pointer pbyte;
    int i;
End
Begin

    // Allocate memory
    pbyte = alloc(elements);

    // Write numbers to bytes
    memset(pbyte,133,elements);

    // Copy bytes to bytearray
    memcopy(&bytearray[0],pbyte,elements);

    // Show numbers
    for(i=0; i<elements; i++)
        say("byte["+i+"] = " + bytearray[i]);
    end

    Repeat
        frame;
    Until(key(_esc))

    // Free the used memory
    free(pbyte);

End

Used in example: alloc(), memset(), say(), free(), array, pointer

Personal tools