The serial receive buffer is an example.
It has a head and tail pointer.
New characters are added to the tail by the receive interrupt, and taken off the head by the "read" method.
Agreed that there are lots of ways to make it work, but the approach I'd rather use is to access the array using an explicit index value for each dimension, which can then be range-checked and wrapped as necessary. IMO this makes for an implementation which can easily be understood and seen to be correct.
PeterH:
Agreed that there are lots of ways to make it work, but the approach I'd rather use is to access the array using an explicit index value for each dimension, which can then be range-checked and wrapped as necessary. IMO this makes for an implementation which can easily be understood and seen to be correct.
I understand the concept of pointers, but I have a hard time using them. I really have to put on my thinking cap so I don't get confused. I think I can figure this out using an index, that seems pretty straight forward.