How to convert String to Characters and/or array within a function

There's probably answer somewhere on the forum, but couldn't see it.
I don't use strings normally but appears to be popular on Arduino??

I'm using an ESP32 firebase library where I need to read back a data string (or character array).
This will normally be over 12 characters.

this is the function I'm using:

if (Firebase.get(firebaseData, "/Project/datastring"))
  {
    mydata = (firebaseData.stringData());    
  }

I want to use a container something like:

char* mydata;
char mydata[64];

I can do this with string to floats:

if (Firebase.get(firebaseData, "/Project/myfloat"))
  {
   myfloat = (firebaseData.stringData().toFloat());
  }

I have been doing this:

display.printf("mystring: %s\n", mystring.c_str());

to display the data, but I need to put this in a container.

Is there a more simple preferred way?

Thank you

what's the type of whatever is returned by Firebase.get()? which library are you using?

if you want a copy of what comes back:

char mydata[64];
if (Firebase.get(firebaseData, "/Project/datastring"))
  {
    strcpy(mydata,firebaseData.stringData().c_str());
  }

blh64:
if you want a copy of what comes back:

char mydata[64];

if (Firebase.get(firebaseData, "/Project/datastring"))
 {
   strcpy(mydata,firebaseData.stringData().c_str());
 }

Thankyou @blh64 that works just fine.

J-M-L:
what's the type of whatever is returned by Firebase.get()? which library are you using?

Sorry @J-M-L, I should have mentioned it's this one:

The data type stored on Firebase is a string (generated from a json array).
I use standard GET function and sort the data when it comes in.
However this is the first time I've used Arduino, generally I use Mbed but can't program on there as the ESP32 is not an ARM core.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.