title: pointers and byte arrays in c++
body: <p>I'm new to pointers and I would like to do a function such that add each byte in memory from an <code>int</code> variable to each cell in an <code>unsigned char</code>. Please, see code below</p>
  
  <pre><code>int main()
  { 
   unsigned char buffer[4] = {0};
   int number = 15
   unsigned char *ptBuffer = &amp;buffer;
  
   return 0;
  }
  </code></pre>
  
  <p>so the output would be </p>
  
  <pre><code>buffer[0]= 0,
  buffer[1]= 0,
  buffer[2]= 0,
  buffer[3]= F
  </code></pre>
  
  <p>so </p>
  
  <pre><code>number = 15 =&gt; 0x000F
  </code></pre>