# PutMemPtr
{: .no_toc }

Writes a pointer-sized value to a memory address.

Syntax: **PutMemPtr** *Address* **,** *Value*

*Address*
: *required* **LongPtr**. The address to write to.

*Value*
: *required* **LongPtr**. The pointer-sized value to store at *Address*.

The number of bytes written matches the host's pointer width --- four bytes in 32-bit builds, eight bytes in 64-bit builds. The bytes are written in the host's native byte order. The address is written directly with no bounds or alignment check.

### Common Errors

| Error | When |
|---|---|
| [94 (`&H5E`)](/Reference/Run-time-Errors.md#94), *Invalid use of Null* | *Address* or *Value* is **Null** |

### Example

This example stores a pointer in a buffer and reads it back.

```tb check_build
Dim buf As LongPtr = AllocMem(8)    ' large enough for a pointer on any platform
Dim target As Long = 42
PutMemPtr buf, VarPtr(target)       ' store the address of target
Dim p As LongPtr
GetMemPtr buf, p                    ' p = address of target
FreeMem buf
```

### See Also

- [PutMem1](/tB/Modules/HiddenModule/PutMem1.md), [PutMem2](/tB/Modules/HiddenModule/PutMem2.md), [PutMem4](/tB/Modules/HiddenModule/PutMem4.md), [PutMem8](/tB/Modules/HiddenModule/PutMem8.md) procedures
- [GetMemPtr](/tB/Modules/HiddenModule/GetMemPtr.md) procedure
