array handling

Hi i've array of numbers i wanna push thru when a new value is coming in: void addSensData() { myArray[4] = myArray[3]; myArray[3] = myArray[2]; myArray[2] = myArray[1]; myArray[1] = myArray[0]; myArray[0] = analogValue; } kindof complicated?! isn't there a syntax in arduino similar to push and pop a stack?

The language is C, and there isn't a native stack data type.

You could just keep an appropriate array index and use the array as a circular buffer; the snippet you provided looks more like a circular buffer than a stack.


thanks kg4wsv for your reply i finally used the following function:

void circularDistBuffer() { for(i = NumberQuantity-1; i > 0; i--){ distBuffer = distBuffer[i-1]; * }* * distBuffer[0] = analogValue;* }