String array problem

Hi,

I have following piece of code:
jsonData is a json string.

String *getDepartures(String jsonData) {
  String departures[] = {jsonData.substring(49, 54), jsonData.substring(99, 104)};
  Serial.println(departures[0]);
  Serial.println(departures[1]);
  return departures;
}

the output here is e.g.
17:40
17:55
both as string. Then I try to return the data and check the output again.

void loop() {
  String *departures = getDepartures(runCurl());
  Serial.println(departures[0]);
}

The output here is then like
:40 but I aspected 17:40

I tried to understand the pointer stuff but ... :disappointed_relieved:
This part for me is clear. That is similar to PHP for me, or I'm completely wrong.

String departures[] = {jsonData.substring(49, 54), jsonData.substring(99, 104)};
Serial.println(departures[0]);
Serial.println(departures[1]);

Some thing on the return of the string is wrong.
small help would be great. Thanks.

The array that you are returning is local to the function. It goes out of scope when the function ends. You should NOT be returning a pointer to a local variable.

Pass the array to store the data to the function. No need to return anything.

huch, so easy, Thanks for that hint.