I am trying to create a class and getting getting the error

incompatible types in assignment of 'const String' to 'char [32]

when I declare

char inString[32];

and try to set it as

inString = server.arg("x");

I tried

inString = server.arg(sizeof("x"));

and got the same error.

full code:

#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
ESP8266WebServer server(80);
const char* ssid = "myssid";
const char* password =  "password";

char inString[32];

void webpage() {
  server.send(200, "text/html", "<html><body><form  name='frm'  method='post'><input type='text' name='x'   ><input type='submit' value='Submit'>   </form></body></html>");
void response(){
  if(server.hasArg("x") && (server.arg("x").length()>0)){ // TODO check that it's not longer than 31 characters
    Serial.print("User entered:\t");
    inString = server.arg("x");
    server.send(200, "text/html", "<html><body><h1>Successful</h1><a href='/'>Home</a></body></html>");
  } else {
    server.send(400, "text/html", "<html><body><h1>HTTP Error 400</h1><p>Bad request. Please enter a value.</p></body></html>");

void setup() {
    WiFi.begin(ssid, password);  //Connect to the WiFi network
    while (WiFi.status() != WL_CONNECTED) {  //Wait for connection
        Serial.println("Waiting to connect...");
    Serial.print("IP address: ");
    Serial.println(WiFi.localIP());  //Print the local IP
    //server.on("/body", handleBody); //Associate the handler function to the path
    server.on("/",HTTP_GET, webpage);
    server.begin(); //Start the server
    Serial.println("Server listening");
void loop() {
    server.handleClient(); //Handling of incoming requests

how to I match my datatypes when using server.arg?

The other post I find related to a pointer which I am not using.

  • 1
    server.arg returns String so use String inString;
    – Juraj
    Commented Jan 2, 2021 at 7:50
  • 1
    @Juraj Worked like a champ! Post it as an answer and I'll give proper thanks.
    – brad
    Commented Jan 2, 2021 at 8:27


Your Answer

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