0
votes

Using an Arduino. I have this code to read a file line by line as a string. This string is then inserted into an http url string. Here is the code. All of this except 'File.....' and 'String addr1' go inside the loop

String addr1 = "https://docs.google.com/forms/.......................14=happy";
String sd_data;
File testfile; // these parts come before void setup()
testfile = SD.open("testdata.txt", FILE_READ); //goes in the loop
while (testfile.available()) {
sd_data = testfile.readStringUntil('\n');

sd_data.replace(' ', '+'); // replace spaces with +
addr1.replace('happy', sd_data);
}

I get this error converting to 'const String' from initializer list would use explicit constructor 'String::String(int, unsigned char)'

1
'happy' or "happy"? - Bo Persson
sorry, what do you mean? - Noel DSouza
'happy' is an integer. Certainly code should be using a string "happy" - somehow. - chux - Reinstate Monica
does that mean sd_data.replace(' ', '+'); is wrong? @chux - Noel DSouza
' ' and '+' are char. Uncertain about Arduino replace(). - chux - Reinstate Monica

1 Answers

0
votes

I've solved the problem, delete

String addr1=.........

instead of

addr1.replace('happy', sd_data);

put

String var="https://docs.google.com/forms/.......................14="+sd_data;