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

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.