invalid conversion from 'char' to 'char*' [-fpermissive]

Hi, can someone explain me why this code fails to compile?

edit: I'm using ARDUINO IDE, AVRISP mkll for generic ESP8266 module

void loop() {
  if (checkConnection()) {
    // Connected to WiFi and MQTT Server
    WiFiClient client = server.available();   // Listen for incoming clients
    if (client) {                             // If a new client connects,
      String data = "";                       // make a String to hold incoming data from the client
      bool isMessage = false;
      char* buffer[HTTP_BUFFER_LENGTH];       // make a buffer to hold incoming data from the client
      int length = 0;                         // length of message
      long unsigned time_ = millis();         
      while (client.connected()) {            // loop while the client's connected
        if (client.available()) {             // if there's bytes to read from the client,
          char c = client.read();             // read a byte, then decide what to do
          if (c == '{') {                     // could be the initial char of a JSON
            isMessage = true;
          }
          if (isMessage == true) {            // if we are reading a message save it
            if (length < HTTP_BUFFER_LENGTH) {
              buffer[length] = c;             // save current char
              length++;                       // go on
              buffer[length] = '\0';           // append null char
            }
          }
          if (c == '}') {                     // the end, parse it and close connection
            client.println("HTTP/1.1 200 OK");
            delay(2);
            client.stop();
            Serial.println(data);             // display result
          }
          if ((long unsigned)millis() - time_ > MAX_HTTP_TIME) {            //max time reached
            client.stop();
          }
        }
      }
    }
  }
  if (Serial.available()) {
    serial_read();                             // To read data from serial and publish in MQTT topic
  }
  client_mqtt.loop();                          // To send data stored in MQTT Buffer
}

It says

invalid conversion from 'char' to 'char*' [-fpermissive]

               buffer[length] = c;             // save current char

                              ^

I can't understand what I'm doing wrong. If you could give me some documentation to read and explain me the problem that would be the best.

EDIT: Now it seems to be ok. I've added the operator & before c. So it looks like this.
buffer[length] = &c;            // save current char Can someone explain me what I just did? It would be really important to me to understand this thoroughly.

Furthermore I've another question: why I can't write something like this:

char string1[16] = "xxx.xxx.xxx.xxx";
  char new_string[16];
  new_string = string1;

the compiler gives me this error: exit status 1, invalid array assignment. So what would be the correct way to handle this?

You declared buffer as holding pointers to characters (char *) and then attempted to put a char there. &c is a pointer to a character so of course that is allowed.

You probably intended to declare buffer as char and not as char* .

You cannot just copy arrays like that. You will need a loop or a function such as memcpy(...).

vaj4088:
You declared buffer as holding pointers to characters (char *) and then attempted to put a char there. &c is a pointer to a character so of course that is allowed.

You probably intended to declare buffer as char and not as char* .

mmh ok. So I ask you what are the differences between pointers and characters? Are there any advantages in using one instead of other?

vaj4088:
You cannot just copy arrays like that. You will need a loop or a function such as memcpy(...).

Not like other languages. I thougth that if the arrays were been the same size, I would have been allowed to copy in that way. I was wrong. So i need to copy item by item.

There is a BIG difference between characters and pointers. If you need to ask the question, it is time to learn. Take a course or read some books about C or C++.

vaj4088:
There is a BIG difference between characters and pointers. If you need to ask the question, it is time to learn. Take a course or read some books about C or C++.

Yeah, I think you're right. :confused: ::slight_smile: