title: Accessing direct memory addresses and obtaining the values in C++
body: <p>I was wondering if it was possible to access a direct block of memory using C/C++ and grab the value. For example:</p>
  
  <pre><code>int i = 15;
  int *p = &amp;i;
  cout &lt;&lt; &amp;i;
  </code></pre>
  
  <p>If I took the printed value here, that would give me the address of the variable i, which contains the value 15. I will just say it printed out 0x0ff9c1 for this example. If I have a separate program which declares a pointer like so...</p>
  
  <pre><code>int *p = 0x0ff9c1;
  cout &lt;&lt; *p;
  </code></pre>
  
  <p>Would it be possible to print out that 15 that the other application placed in the memory block 0x0ff9c1? I know my pointer declaration with the memory address is incorrect, I am unsure how to do it otherwise. I have tried using <code>memcopy</code> but I have not been able to get that to work either. I know this is possible somehow as I have a program called Cheat Engine which modifies game memory address values to gain unfair advantages. I have been successful in placing the printed memory location and obtaining the value (15) though Cheat Engine. My goal is to do this using C++. 
  If this is too confusing, basically I would like to access a variable that another application stored using its memory address and print out the value. I am using Windows 7 x64 with MinGW compiler if that matters. Thanks!</p>
  
  <p>PS: I'll post a picture of what Cheat Engine does to give a better idea.
  <img src="https://i.stack.imgur.com/4tVbf.png" alt="enter image description here"></p>