exit status 1 invalid operands of types 'const char [5]' and 'const char [2]' to binary 'operator+'
String message = "Page not found\n\n";
message += "URI: " + HTTP.uri() + "\n";
message += "Method: " + (HTTP.method() == HTTP_GET)? "GET": "POST" + "\n";
message += "Arguments: " + HTTP.args() + "\n";
2 Answers 2
The operators of the class String apply only for an instance of String. In your expression you concatenate two c-strings "POST" + "\n"
answered Feb 23, 2018 at 18:29
A simple fix is to just move the (const char *)s around a little:
This should compile
String message = "Page not found\n\n";
message += "URI: " + HTTP.uri() + "\n";
message += "Method: " + (HTTP.method() == HTTP_GET)? "GET\n": "POST\n";
message += "Arguments: " + HTTP.args();
message += "\n";
answered Feb 24, 2018 at 12:30
((HTTP.method() == HTTP_GET)? "GET": "POST")