Help with using strings/character arrays as parameters in a function

Hey! This is my post here, this is kind of daunting, haha.

Anyway, I'm trying to make a function that plugs phrases defined in the main function into sentences defined in a function I created. However, I'm having major issues with the "plugging" aspect of it, AKA determining what kind of variable should store the phrases and how to put them into the function.

I've tried using the string and char* variables. I decided to go with the char* variable in the end because that's what the error compiler told me it was. Here's the error I get when I run the program with a char* variable:

C:\Users\username\Desktop\Arduino\testing\testing.ino: In function 'void loop()':
testing:11:59: error: cannot convert 'const char*' to 'char**' for argument '1' to 'char* instructions(char**)'
   instructions("placer1", "placer2", "placer3");

I also tried out a const char*, but it also doesn't work. It always adds an extra asterisk in the error (like const char** if I already have one), so I don't think it perceives it as a pointer.

Here's the full code

void loop() {
  instructions("placer1", "placer2", "placer3");
}

char* instructions(char* text[2]){
  Serial.print("Welcome to ");
  Serial.println(text[0]);
  delay(2000);
  
  Serial.print("Here, your goal is to react faster than ");
  Serial.println(text[1]);
  delay(4000);
  
  Serial.print("The game ends when ");
  Serial.println(text[2]);
  delay(3000);

  for (int y = 3; y > 0; y--){
    Serial.print(y);
    Serial.println("...");
    delay(1000);
  }
  Serial.println("GO!");
}

Your instructions function is defined as taking a single parameter. You're giving it three. The compiler isn't going to combine them into an array for you. Try changing the function to have three char * parameters instead.

Yeah, I legit solved this 10 minutes after posting after being stuck in it for an hour yesterday…

I changed it to “void instructions(String one, String two, String three)” and it worked like a charm.

Thanks for replying, wildbill.

Are you aware of the potential memory corruption possible with the use of the String class? See the evils of Strings.