RawMemoryWrite[ptr,val]
writes a binary representation of val to the raw memory at the pointer ptr.
RawMemoryWrite[ptr,val,offset]
writes to an offset pointer.
RawMemoryWrite
RawMemoryWrite[ptr,val]
writes a binary representation of val to the raw memory at the pointer ptr.
RawMemoryWrite[ptr,val,offset]
writes to an offset pointer.
Details
- Supported values of ptr include RawPointer expressions and ManagedObject expressions whose values are pointers.
Examples
open all close allBasic Examples (2)
Allocate an object of type "CInt":
ptr = RawMemoryAllocate["CInt"];Write a value to the raw memory:
RawMemoryWrite[ptr, -1]RawMemoryRead[ptr]Allocate a raw memory of 10 objects of type "CFloat":
buffer = RawMemoryAllocate["CFloat", 10];Initialize the raw memory with random numbers between 0 and 1:
Do[RawMemoryWrite[buffer, RandomReal[], i], {i, 0, 9}]Import the values of the raw memory as a list:
RawMemoryImport[buffer, {"List", 10}]Scope (1)
RawMemoryWrite supports passing a managed pointer as its first argument:
ptr = RawMemoryAllocate["CFloat"]RawMemoryWrite[ptr, 3.14]It also supports passing a non-managed pointer:
rawPtr = UnmanageObject@ptrRawMemoryWrite[rawPtr, 3.14]Properties & Relations (1)
Allocate a buffer of 5 objects of type "Integer16" and fill it with the value -1:
ptr = RawMemoryAllocate["Integer16", 5];
Do[RawMemoryWrite[ptr, -1, i], {i, 0, 4}]RawMemoryExport can be used for the same purpose:
RawMemoryExport[ConstantArray[-1, 5], "Integer16"]Tech Notes
Related Guides
History
Text
Wolfram Research (2023), RawMemoryWrite, Wolfram Language function, https://reference.wolfram.com/language/ref/RawMemoryWrite.html.
CMS
Wolfram Language. 2023. "RawMemoryWrite." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/RawMemoryWrite.html.
APA
Wolfram Language. (2023). RawMemoryWrite. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/RawMemoryWrite.html
BibTeX
@misc{reference.wolfram_2026_rawmemorywrite, author="Wolfram Research", title="{RawMemoryWrite}", year="2023", howpublished="\url{https://reference.wolfram.com/language/ref/RawMemoryWrite.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_rawmemorywrite, organization={Wolfram Research}, title={RawMemoryWrite}, year={2023}, url={https://reference.wolfram.com/language/ref/RawMemoryWrite.html}, note=[Accessed: 13-June-2026]}