I am trying to achieve a "wrap around" effect in a circular array. When I push an item to front, I want it to be stored in decreasing locations. When I push to front, I'm trying something like this:
items[front] = ch; front = (front - 1) % capacity;
But this does not wrap around like I would expect. Front starts out at 0, and when the second line executes, front becomes -1. Shouldn't front become 6 after the second line executes? My data structures textbook seems to think so.