title: How can I use memcpy to copy data from two integers to an array of characters?
body: <p>I have a file that can store up to 8 bytes of data.</p>
  
  <p>I have a system(let's call is Sys1) which can bring me 8 bytes from the file and save it in a buffer inside the ram.</p>
  
  <p>I can use these 8 bytes and copy some stuff in it, and then use this system to say "OK I'm done with it, just send these data back to the file".</p>
  
  <p>I want to bring the 8 bytes to the buffer, copy an integer to it, which takes 4 bytes, and on the remaining 4 bytes copy another integer. I just want two integers in 8 bytes, which I believe can be done.</p>
  
  <p>I have managed to copy 4 bytes only, which is just 1 integer and managed to send it back to the file. So I have something like this:</p>
  
  <pre><code>     char *data;
       sys1.bring_the_8_bytes(&amp;data);
      //now the 8 bytes are in the buffer,
      // data points to the first byte of the 8 byte  sequence
      int firstInteger = 10;
      int secondInteger = 20;
      //the two integers 
      memcpy(data,&amp;firstInteger,sizeof(int));
      //now the values of the first integer have been copied successfully.
      sys1.send_the_8_bytes_back();
  </code></pre>
  
  <p>now this works fine! However I'm not sure how to copy the first integer and then the second immediately.</p>
  
  <p>I should actually know the address of the first byte that is exactly after the last byte that is taken by the first integer, and then use this address as a destination address in the memcpy call, is my thinking correct? if yes, </p>
  
  <p>how can I achieve this?? How can I find out this address that I want?</p>
  
  <p>thanks in advance</p>