I created a function to retrieve date from a esp32 using c++. Buts it's causing a error.
I see dozens of sites and none of solutions worked to me. The code can change to a better practice if you provide it.
the ideia is. create a function to return a DateTime in a char.
void getCurrentDateTime(char **datetime){
time_t tt = time(NULL);
data = *gmtime(&tt);
strftime(datetime, 64, "%m/%d/%Y %H:%M:%S", &data);
}
I call that function this way.
char *datetime;
getCurrentDateTime(&datetime); // my function
The code compiles but crash the esp32 device...
I'm in very beginning of c++ code... so i appreciate if you explain and provide a code for function and a how to call it.