I have uses the Array of Strings Example from:
The Arduino programming language Reference, organized into Functions, Variable and Constant, and Structure keywords.
as a template, but the compiler sends back the following error on loading the sketch:
warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]
now, the sketch runs; but what is this error, how can it be corrected, or is there a prefered method of creating the array of strings?
Can you show the word "error" in what you posted?
Make them const .
const char *myStrings[] = {"This is string 1", "This is string 2", "This is string 3",
"This is string 4", "This is string 5", "This is string 6"
};
It's a compiler setting that allows to treat this error as a warning.
The terms String and string mean different things and are not interchangable.
A string is a null terminated character array aka c_string.
A String is an object of the String class.
Whether this is flagged as a warning or an error will depend on how permissive the compiler options are set. Some board packages, such as for the ESP8266, use less permissive settings.
1 Like
system
Closed
April 9, 2022, 9:15pm
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.