title: How to get the first x elements of a char array in C? Is there an improved way with boost-libraries?
body: <p>My basic task is to get a subset of an buffer-array into another buffer array:</p>
  
  <pre><code>char buffer[max_len];
  
  unit8 *pDestBuffer;
  </code></pre>
  
  <p>I used this code, because I would like to stay in ANSI-C:</p>
  
  <pre><code>memcpy(pDestBuffer, buffer, 4);
  </code></pre>
  
  <p>However - something must be wrong, because I don't get my result as I expect to. Because, when I debug buffer, I see all the <em>slots</em> of the array - when I do this with pDestBuffer, I get only one Item - which I can change however, with something like <code>memset(pDestBuffer,1,4)</code></p>
  
  <p>pDestBuffer is part of a structure, and the only other reference to it, besides the definition above, was were these lines:</p>
  
  <pre><code>requiredMemory = sizeof(Structure) + bufferSize;
  pStructure = (Structure *)HostMalloc(requiredMemory);
  pStructure-&gt;pDestBuffer = ((uint8 *)pStructure)+sizeof(Sturcture);
  </code></pre>
  
  <p>I know, this might be rather a basic task, and I am working on this myself, but please, if there is a "best-practice" for this or you know a solution, please share it with me.</p>
  
  <p>As a twist, I would really like to know, if there might be an improved way for this, using the boost-libraries, which I do use anyways for other problems.</p>