title: Why does this code use a *char as a buffer pointer?
body: <p>In looking for circular buffer code to reuse, I've come across a use of char which confuses me</p>
  
  <pre><code>typedef struct CircularBuffer
  {
      void *buffer;     // data buffer
      void *buffer_end; // end of data buffer
      size_t capacity;  // maximum number of items in the buffer
      size_t count;     // number of items in the buffer
      size_t sz;        // size of each item in the buffer
      void *head;       // pointer to head
      void *tail;       // pointer to tail
  } CircularBuffer;
  
  void cb_push_back(CircularBuffer *cb, const void *item)
  {
      if(cb-&gt;count == cb-&gt;capacity)
          // handle error
          memcpy(cb-&gt;head, item, cb-&gt;sz);
  
      ////////////// here's the part I don't understand //////////
      cb-&gt;head = (char*)cb-&gt;head + cb-&gt;sz;
      //////////////////////////////////////////////////////////
  
      if(cb-&gt;head == cb-&gt;buffer_end)
          cb-&gt;head = cb-&gt;buffer;
      cb-&gt;count++;
  }
  </code></pre>
  
  <p>Why cast this void pointer to a char? Is this some sort of C idiom (I have very limted C expereience)? A away convenient way to increment a pointer perhaps?</p>
  
  <p>The use of a char for the position pointer comes up again in some different buffer code as well:</p>
  
  <pre><code>/**&lt; Circular Buffer Types */
  typedef unsigned char INT8U;
  typedef INT8U KeyType;
  typedef struct
  {
      INT8U writePointer; /**&lt; write pointer */
      INT8U readPointer;  /**&lt; read pointer */
      INT8U size;         /**&lt; size of circular buffer */
      KeyType keys[0];    /**&lt; Element of ciruclar buffer */
  } CircularBuffer;
  </code></pre>
  
  <p>Again, this looks like some sort of handy trick that C programmers know about, something about pointers being easy to manipulate if they're chars. But I'm really just speculating.</p>