title: Attempted to read or write protected memory. This is often an indication that other memory is corrupt
body: <p>I am working on some implementation of brute force algorithm and this seems like a basic question but I can't make it work.</p>
  
  <p>Following line of code breaks program:</p>
  
  <pre><code>found[next] = j;
  </code></pre>
  
  <p>Declaration of array:</p>
  
  <pre><code>int* found = new int[30];
  </code></pre>
  
  <p>j is counter that is increasing in for-loop. Code like found[0] = 0 works OK. If I use variables for index and value it crashes. Error in Visual Studio 2012 is "Attempted to read or write protected memory. This is often an indication that other memory is corrupt".</p>
  
  <p>I use int* becouse it's in c++ dll that I use with c# application.</p>