read function works fine but calling function gets nothing

My read function returns an array of strings. i.e ssid and password

    String* configuration::read() {
        String rw_ssid = "";
        String rw_pswd = "";
        const int keys = 2;
        String read_ssid_pswd [keys];
        if (EEPROM.read(0) != 0) {
      
          for (int i = 0; i < 32; ++i) {
            rw_ssid += char(EEPROM.read(i));
          }
          for (int i = 32; i < 96; ++i) {
            rw_pswd += char(EEPROM.read(i));
          }
          Serial.print("rPASSWORD: ");
          Serial.println(rw_pswd);
          read_ssid_pswd[0] = rw_ssid;
          read_ssid_pswd[1] = rw_pswd;
          Serial.print("Sending ssid:");
          Serial.print(read_ssid_pswd[0]);
          Serial.print(" Pswd: ");
          Serial.println(read_ssid_pswd[1]);
          return read_ssid_pswd;
        } else {
          Serial.println("Data wifi not found!");
          return read_ssid_pswd;
        }
    }

I can see the print

Sending ssid:SSID Pswd: password

but where this function is called from I have set it up like this:

      String* ssid_password = Eeprom::configuration::read();
      Serial.print(">SSID: ");
      Serial.println(ssid_password[0]);
      Serial.print(">Password: ");
      Serial.println(ssid_password[1]);

and I get thing in the prints I thought its not giving any error at compile time so it should be correct.

ssid_password[keys] is an array of string objects. ssid_password is the address of that array, but the array is a local variable and goes out of scope when your function ends.

Returning a pointer to a local variable is always a bad idea, but doubly so here as I expect that the destructor was called for each element of the array and the memory it was using was freed.

Net net, this isn't going to work.

wildbill:
Returning a pointer to a local variable is always a bad idea, but doubly so here as I expect that the destructor was called for each element of the array and the memory it was using was freed.

variables local to a function are allocated on the stack. that portion of stack is used from something else when the function returns.

while not the best approach, try making ssid_pswd "static" so that it a not allocated on the stack, but persistent between function calls

  static String read_ssid_pswd [keys];

if I declare array read_ssid_pswd in the setup method and pass it as arg to the read function ?

  const int keys = 2;
  String read_ssid_pswd[keys];
  SensorData::read_sensor_data::initializeADC();
  Eeprom::configuration::initialize();
  read_ssid_pswd = Eeprom::configuration::read(read_ssid_pswd);

but when I compile I get this error:

incompatible types in assignment of 'String*' to 'String [2]'

and in the configuration header file

namespace Eeprom
{
  class configuration 
  {
    public:
      .
      static String* read(String* read_ssid_pswd);
      .
  };
}

what am I doing wrong here ?