Answer the question
In order to leave comments, you need to log in
How to fix invalid operands of types 'const char*' and 'const char [7]' to binary 'operator+' error?
Hello. I am writing a web interface for the eeprom parser for esp8266.
When compiling it says:
In function 'void rw_eeprom()':
1Both_mode:121:187: error: invalid operands of types 'const char*' and 'const char [7]' to binary 'operator+'
121 | server.send(200, "text/html", "<title>R/W Eeprom</title><link rel=\"stylesheet\" href=\"/style.css\"> <h1 style=\"text-align:center\">Read - Success! </h1> <br><pre>"+(val)+"</pre>");
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
| | |
| | const char [7]
| const char*
exit status 1
invalid operands of types 'const char*' and 'const char [7]' to binary 'operator+'
byte val = EEPROM.read(server.arg("addr").toInt());
server.send(200, "text/html", "<title>R/W Eeprom</title><link rel=\"stylesheet\" href=\"/style.css\"> <h1 style=\"text-align:center\">Read - Success! </h1> <br><pre>"+val+"</pre>");
return;
Answer the question
In order to leave comments, you need to log in
In server.send, replace val with (String)val
This way you convert the variable to a string type that can be added to a string.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question