Search code examples
c++visual-studiodebuggingcopymemory-address

How to copy variable address in Visual Studio


In the watching window I can add & before a variable to see its address, but how to copy it's address?

I can create a new pointer to this variable in order to copy the pointer's value (the var's address) in watching window. But how to copy the address directly?


Solution

  • You just need to drag and drop the address into the memory window

    Selecting a Memory Location

    If you want to move instantly to a selected location in memory, you can do so by using a drag-and-drop operation or by editing the value in the Address box. The Address box accepts not only numeric values but also expressions that evaluate to addresses. By default, the Memory window treats an Address expression as a live expression, which is reevaluated as your program executes. Live expressions can be very useful. For example, you can use them to view the memory that is touched by a pointer.

    To select a memory location by dragging and dropping

    • In any window, select a memory address or pointer variable that contains a memory address.
    • Drag the address or pointer to the Memory window.

    MSDN - Memory Windows - select a memory location