Hi,
in the past I was only read some entrys here and they helped me much to realize my little projects. Thank you all for that.
Now I have a special problem and found no solving for that.
I use a ESP32 to get the actual time from a time server pool.
WiFiUDP ntpUDP;
NTPClient timeClient(ntpUDP, "de.pool.ntp.org");
.
.
.
So far that's working fine.
Now I had the idea to change the time server name in the running system.
To try if it's working I stored the Server name in a character array:
char *server = "de.pool.ntp.org";
NTPClient timeClient(ntpUDP, server);
.
.
.
This is working fine also.
Unfortunetly the server names are stored in strings. I tried the following code:
string timeServer = "de.pool.ntp.org";
char Time_Server[timeServer.length()+1];
timeServer.toCharArray(Time_Server, timeServer.length()+1);
char *server = Time_Server;
NTPClient timeClient(ntpUDP, server);
.
.
.
This is not working.
There is a different between
char *server = "de.pool.ntp.org";
and
char *server = Time_Server;
whereby Time_Server is a character array.
I know I have a comprehension gap in using pointers and I worked through some lessons and tried some other things in the last days but I couldn't find the solving.
Could somewhere explain me what's wrong?
Thank you very much.
Ralf