Apple Interview Question

Write code for writing to a circular buffer.