Termination requirement of setPoolServerName() parameter #217
Labels
topic: code
Related to content of the project itself
type: imperfection
Perceived defect in any part of project
setPoolServerName()
does not accept output from functionc_str()
as a parameter.I believe this is because, unlike functions in other related libraries (such as ESP8266WiFi's
begin()
), NTPClient'ssetPoolServerName()
does not delimit the char array and the null terminator is (perhaps incorrectly) being processed as part of the parameter.In the following example, I read the desired NTP server name from a file as a
String
usingf.readStringUntil()
which returns aString
of characters up to but not including delimiter'\n'
(0xA), and pass it tosetPoolServerName()
viac_str()
. This does not work (NTPClient fails to set the correct pool server name).In the following example, I read the same NTP server name from a file a char at a time into a
char
array which I then pass tosetPoolServerName()
and this works fine.In both examples, the file contains 'time.windows.com' and both examples correctly return a size of 16 characters (the
String.length()
of course does not count the null terminator).The text was updated successfully, but these errors were encountered: