Differenze tra le versioni di "Memcpy ()"
Da Gambas-it.org - Wikipedia.
Riga 9: | Riga 9: | ||
− | Semplice esempio uso in Gambas: | + | Semplice esempio di uso in Gambas: |
<FONT color=Gray>' ''wchar_t * memcpy(wchar_t * dest, Const wchar_t * src, size_t count)''</font> | <FONT color=Gray>' ''wchar_t * memcpy(wchar_t * dest, Const wchar_t * src, size_t count)''</font> | ||
'''Private''' <FONT color=#B22222>Extern memcpy</font>(dest As Pointer, src As Pointer, count As Integer) As Pointer In "<FONT color=#B22222>libc:6</font>" | '''Private''' <FONT color=#B22222>Extern memcpy</font>(dest As Pointer, src As Pointer, count As Integer) As Pointer In "<FONT color=#B22222>libc:6</font>" |
Versione delle 05:13, 7 feb 2014
La funzione della libreria di C
void *memcpy(void *str1, const void *str2, size_t n)
copia n caratteri da un'area di memoria str2 ad un'altra area di memoria str1.
Volendola utilizzare in Gambas, bisognerà dichiararla con Extern, nonché bisognerà dichiarare la libreria di C: libc.so.6, nella quale la funzione è contenuta:
Private Extern memcpy(dest As Pointer, src As Pointer, count As Integer) As Pointer In "libc:6"
Semplice esempio di uso in Gambas:
' wchar_t * memcpy(wchar_t * dest, Const wchar_t * src, size_t count) Private Extern memcpy(dest As Pointer, src As Pointer, count As Integer) As Pointer In "libc:6" Public Sub Form_Open() Dim a, b As Pointer Dim num As Integer a = Alloc(SizeOf(gb.Integer)) b = Alloc(SizeOf(gb.Integer)) num = 999 a = VarPtr(num) memcpy(b, a, SizeOf(gb.Integer)) Print Int@(b) End