title: How can I write to a buffer (void pointer)?
body: <p>I want to write in 2 chars and a bit vector (uint64_t) to a file, but I first have to write them all to a buffer. Then the buffer will be written to the file. How should I write these 3 variables into a buffer (void pointer) so that all can be contained within one (void pointer) variable.</p>
  
  <p>For example I want to write</p>
  
  <pre><code>char a = 'a';
  char b = 'b';
  uint64_t c = 0x0000111100001111;
  </code></pre>
  
  <p>into</p>
  
  <pre><code>void *buffer = malloc(sizeof(char)*2+sizeof(uint64_t));
  </code></pre>
  
  <p>Then write that into a file using</p>
  
  <pre><code>write(fd, buffer, sizeof(char)*2+sizeof(uint64_t));
  </code></pre>