Restored from previous forum. Originally posted by waffle.
not sure if this is a "beginner question"....
the recieve network data function places the data into a buffer
thusly... *Buffer
i can recieve a pointer to a structure by *Mystruct
how do i quickly copy the data from Buffer to Mystruct ?
copy memory only works with memory addresses (or was that ID)
is this where i would use inline assembly with a code like
mov @buffer,size to @Mystruct ?
it seems like another simple question from me,
but i don't have a boom on that.... yet.
pointer question
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by Pupil.
Just some caution, the struct pointer MUST point to a variable(of same structure) or memory that you have previously allocated or your program would crash for sure. I.e. something like this:
You could use the copymemory() command, the manual states that the 'SourceMemoryID' and 'DestinationMemoryID' is the memory address that you want to copy from and copy to. This would do i guess:Originally posted by waffle
not sure if this is a "beginner question"....
the recieve network data function places the data into a buffer
thusly... *Buffer
i can recieve a pointer to a structure by *Mystruct
how do i quickly copy the data from Buffer to Mystruct ?
copy memory only works with memory addresses (or was that ID)
is this where i would use inline assembly with a code like
mov @buffer,size to @Mystruct ?
it seems like another simple question from me,
but i don't have a boom on that.... yet.
Code: Select all
CopyMemory(*buffer, *Mystruct.YourStructType, SizeOf(YourStructType))
Code: Select all
var.YourStructType
*MyStruct.YourStrucType = @var
; or memory
*MyStruct.YourStructType = AllocateMemory(0, SizeOf(YourStructType), 0)
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
-
BackupUser
- PureBasic Guru

- Posts: 16777133
- Joined: Tue Apr 22, 2003 7:42 pm
Restored from previous forum. Originally posted by waffle.
actually, i found the root cause of my confusion....
*F reserves a variable for the use as an actual address (pointer)
@F returns the actual address that must be stored into a pointer....
*F+25 shift the address of *F by 25 bytes
this stuff is coming back to me
actually, i found the root cause of my confusion....
*F reserves a variable for the use as an actual address (pointer)
@F returns the actual address that must be stored into a pointer....
*F+25 shift the address of *F by 25 bytes
this stuff is coming back to me