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

answered Feb 23, 2018 at 18:29
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";
answered Feb 24, 2018 at 12:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.