title: Using memcpy is causing overwrite of memory to NULL
body: <p>Issues with memcpy</p>
  
  <p>Working on a C project using Eclipse CDT </p>
  
  <p>The strangest thing is happening! 
  When I debug I see that <strong>iu1</strong> values are getting overwritten after two iterations in the for loop. </p>
  
  <p>I have editted this question now. </p>
  
  <p>Please look at the code below. </p>
  
  <pre><code>typedef struct IUnitStruct
  {
      long ptr;
      char key[1];
  }iUnit;
  
  
  
  
  
  void createInternalNode(internalNode ** n)
  
  {
  
          int iUnitSizeJump = 1012 ;
          iUnit* iu1 = (iUnit*) malloc(iUnitSizeJump);
          iu1-&gt;ptr = -1;
          strcpy(iu1-&gt;key,"NullKey1");    
  
          iUnit* iu2 = (iUnit*) malloc(iUnitSizeJump);
          iu2-&gt;ptr = -2;
          strcpy(iu2-&gt;key,"NullKey2");
  
          for (int i = 0 ; i &lt; 8; i=i+2 )
          {
              memcpy(&amp;(*n)-&gt;iunit[(i)*(iUnitSizeJump)],iu1,iUnitSizeJump);
              memcpy(&amp;(*n)-&gt;iunit[(i+1)*(iUnitSizeJump)],iu2,iUnitSizeJump);
          }
      }   
  
  
  
  void printNode(internalNode *n, int iUnitSize)
  {
  
      for (int i = 0 ; i &lt; 8; i++ )
  
      {
  
          cout &lt;&lt; "||Page:" ;
  
          cout &lt;&lt; n-&gt;iunit[i*iUnitSize].ptr;
  
          cout &lt;&lt; "|";
  
          cout &lt;&lt; n-&gt;iunit[(i*iUnitSize)].key;
  
          cout &lt;&lt; "|| ";
  
      }
  
  
  }
  </code></pre>
  
  <p>Here is the Output </p>
  
  <pre><code>||Page:-1|NullKey1||
  
  ||Page:-2|NullKey2|| 
  
  ||Page:0||| 
  
  ||Page:-2|NullKey2|| 
  
  ||Page:0||| 
  
  ||Page:-2|NullKey2||
  
  ||Page:0|||
  
  ||Page:-2|NullKey2|| 
  </code></pre>
  
  <p>I need it to show</p>
  
  <pre><code>||Page:-1|NullKey1||
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>||Page:0|||
  </code></pre>