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

2 Answers 2

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 and acknowledge you have read our privacy policy.

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