Apple interview question

Write code for writing to a circular buffer.