Trouble with arrays

I have successfully used simple arrays in the past but never tried to update them... just read them.
So now I wrote this simple little sketch but as in this example, when I update the 3rd element with 'bbbbb', (OK). Then when I update then 4th element with 'ccccc' both it and the 3rd element are changed to 'ccccc'. Here I have updated 3 and 4 in that order but the same thing happens if I update them in the reverse order.

Update: After posting this I found that in the 'results' below the sketch, elements 3-4 are ccccc but when I copied them here they show as aaaaa (the original contents of the element). Huh?

  const char*  array[] = { "11111" , "22222" , "33333" , "44444" , "55555"};


  char f1[6] = {"aaaaa"};
 
const char* f2 = "bbbbb";
const char* f3 = "ccccc";

void setup() {
  // put your setup code here, to run once:
   Serial.begin(9600);
   Serial.println(" ");
  Serial.println(array[0]);
  Serial.println(array[1]);
  Serial.println(array[2]);
  Serial.println(array[3]);
  Serial.println(array[4]);
  
   strcpy(f1,f2);
   array[3] = f1;
  Serial.println(" ");
  strcpy(f1,f2);

  Serial.println(array[0]);
  Serial.println(array[1]);
  Serial.println(array[2]);
  Serial.println(array[3]);
  Serial.println(array[4]);

  strcpy(f1,f3);
  array[4] = f1;
   
  Serial.println("------------------------------ ");
  Serial.println(array[0]);
  Serial.println(array[1]);
  Serial.println(array[2]);
  Serial.println(array[3]);
  Serial.println(array[4]);
  Serial.println("-------------------------------- ");
  
}

void loop() {
  // put your main code here, to run repeatedly:

}
==========Results shown below ===================
11111
22222
33333
44444
55555
 
11111
22222
33333
bbbbb
55555
------------------------------ 
11111
22222
33333
aaaaa
aaaaa
-------------------------------- 

You have updated the array so that elements 3 and 4 point to the same string, so when you print them, you will see the same value twice.

  array[3] = f1;
  ...
  array[4] = f1;

It won't make any difference which order you do these assignments, the result will be the same.

Maybe what you don't understand yet is that this is not an array of strings. It's an array of pointers to strings.

Wow... thanks for the fast reply. As you may have guessed, I am something of a lightweight here. Not real strong on using pointers. But here is my problem... in my 'real' sketch I am attempting to fill a small array with time/date stamps and keep just the last several entries for display. Could you suggest how I would accomplish that?

Yes, thanks you... I realized that after your first post.

Safest way would be to use strcpy() only, don't update the array with assignments (=) because that is changing the pointers.

Using assignment to change the pointers would be more efficient, but because your array is small, I don't think efficiency will be an issue here.

This is not what your code outputs, it outputs

ccccc
ccccc

as expected, because as explained already both elements are pointers that point to the same memory.

@fatfenders
All your variables except of f1 are pointers to the string literals. literals are not meant to be changed after creation, so the compiler can use the same literal for multiple variables.
So you shouldn't try to assign a new values to it.
If your string variable need to be changed during the program run - use a char arrays instead of literals:

See the difference
Literal:

char* a = "AAAAA";

Array of chars:

char b[] = "AAAAA";

Is there a difference?

See the example

char* a = "aaaaa";
char* b = "aaaaa";
char c[] = "bbbbb";
char d[] = "bbbbb";
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Serial.println(" === Before === ");
Serial.print("  a = "); Serial.println(a);
Serial.print("  b = "); Serial.println(b);
Serial.print("  c = "); Serial.println(c);
Serial.print("  d = "); Serial.println(d);
a[2] = '_';
c[2] = '_';
Serial.println(" === After === ");
Serial.print("  a = "); Serial.println(a);
Serial.print("  b = "); Serial.println(b);
Serial.print("  c = "); Serial.println(c);
Serial.print("  d = "); Serial.println(d);
}

void loop() {
  // put your main code here, to run repeatedly:

}

Output:

=== Before === 
  a = aaaaa
  b = aaaaa
  c = bbbbb
  d = bbbbb
 === After === 
  a = aa_aa
  b = aa_aa
  c = bb_bb
  d = bbbbb

Thanks, I get it now!

Thanks again. Your advice coupled with time spent going back and reading/understanding arrays, pointers, etc. got me back on track. I solved it by going to a 2D array :

char array[5][6] = { "11111" , "23456" , "33333" , "44444" , "55555"};
char f1[6] = {"zxcvb"};

and...

for (int nc =0; nc < 5; nc++) {array[4][nc] = f1[nc];}

const

it is example to the post #8, where there is no const