0

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";
  • which line is it having problems with? – Chad G Feb 23 '18 at 17:49
  • try enclosing the ternary operator in brackets ((HTTP.method() == HTTP_GET)? "GET": "POST") – jsotola Feb 23 '18 at 17:54
2

The operators of the class String apply only for an instance of String. In your expression you concatenate two c-strings "POST" + "\n"

0

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";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.