Streaming Elements to an array

I'm streaming char[13] arrays (8.3 file names) into an array char [n][13] array. Assuming that the number of char[13] arrays is greater than n, is there a way to make the array delete element 0, shift everything down one number, and add a new element as element n?

For Example: if n=2 and the following elements were sent into the array:

[element 1]
[element 2]
[element 3]
[element 4]
[element 5]

the array would contain:
[element 4]
[element 5]

Yes, you could simply write code to do exactly what you said, as you described it. However, the indexes would not shift. In other words, your new array would not have the bounds 1-13 instead of 0-12. It's hard to imagine what you'd need that for. But a "circular buffer" is more efficient. Google it.

If you need to keep track of how many you've received in total, do it separately.

Or, if you do want to move them, perhaps something like this:

char *myArray[] = {
  "This is 1", "This is 2", "This is 3", "This is 4",
  "This is 5", "This is 6", "This is 7", "This is 8"

void setup() {
  int n;
  int elements;

  elements = sizeof(myArray) / sizeof(myArray[0]);
  Serial.print("elements = ");
  for (int i = 0; i < elements; i++) {

  n = 2;      // Do move from here up
  memcpy(&myArray, &myArray[n], (elements - n)* sizeof(char *));

  for (int i = 0; i < elements - n; i++) {

void loop() {

That is what I meant, just coding the verbal description. :slight_smile: No mysterious algorithms involved.