title: How to resolve "invalid operands of types" in an Arduino program?
body: <p>It's a manipulation of two codes.</p>
  
  <p>First I send the latitude and longitude value found from the gps module by sms(arduino,gsm module), then by another code I send it to a php file in the server by using http protocol(arduino+gps/gsm/gprs shield). Now when I am merging two codes, it's showing errors like below:   </p>
  
  <pre><code>Arduino: 1.8.10 (Windows 10), Board: "Arduino/Genuino Uno"
  
      C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino: In function 'void getGPSLocation()':
  
    Hajji_Tracker:58:29: error: invalid operands of types 'const char [12]' and 'char [16]' to binary 'operator+'
  
   Serial.println("Latitude  :"+latitude);
  
              ~~~~~~~~~~~~~^~~~~~~~~
  
  Hajji_Tracker:59:30: error: invalid operands of types 'const char [13]' and 'char [16]' to binary 'operator+'
  
   Serial.println("Longitude  :"+longitude);
  
              ~~~~~~~~~~~~~~^~~~~~~~~~
  
  C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino: In function 'void sendTabData(String, int, boolean)':
  
  Hajji_Tracker:91:18: error: incompatible types in assignment of 'String' to 'char [16]'
  
   latitude = data[3];
  
                ^
  
  Hajji_Tracker:92:18: error: incompatible types in assignment of 'String' to 'char [16]'
  
   longitude =data[4];
  
                ^
  </code></pre>
  
  <pre><code>
  C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:138:32: warning: invalid conversion from 'String*' to 'uint8_t {aka unsigned char}' [-fpermissive]
  
       serialSIM808.write(latitude);   // Add id to the url
  
                                  ^
  
  In file included from C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:1:0:
  
  C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note:   initializing argument 1 of 'virtual size_t SoftwareSerial::write(uint8_t)'
  
     virtual size_t write(uint8_t byte);
  
                    ^~~~~
  
  C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:144:33: warning: invalid conversion from 'String*' to 'uint8_t {aka unsigned char}' [-fpermissive]
  
       serialSIM808.write(longitude);   // Add value to url
  
                                   ^
  
  In file included from C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino:1:0:
  
  C:\Program Files (x86)\Arduino\hardware\arduino\avr\libraries\SoftwareSerial\src/SoftwareSerial.h:102:18: note:   initializing argument 1 of 'virtual size_t SoftwareSerial::write(uint8_t)'
  
     virtual size_t write(uint8_t byte);
  
                    ^~~~~
  
  C:\Users\rafez\OneDrive\Documents\Arduino\Hajji_Tracker\Hajji_Tracker.ino: In function 'void loop()':
  
  Hajji_Tracker:169:37: error: cannot convert 'char*' to 'String*' for argument '1' to 'void gsm_send_data(String*, String*)'
  
       gsm_send_data(latitude,longitude);
  
                                       ^
  
  Multiple libraries were found for "SoftwareSerial.h"
   Used: C:\Program
  exit status 1
  invalid operands of types 'const char [12]' and 'char [16]' to binary 'operator+'
  </code></pre>
  
  <p>I have tried many things but can't get rid of these problems. How can I get my code to compile?</p>
  
  <p>Here is my code:</p>
  
  <pre><code>#include &lt;SoftwareSerial.h&gt;
  
  SoftwareSerial serialSIM808(11, 10); //Arduino(RX=11), Arduino(TX=10) //you can replace these with any other pins
  //Arduino(RX) to SIM808(TX)
  //Arduino(TX) to SIM808(RX)
  //Arduino(Gnd) to SIM808(Gnd)
  
    String data[5];
    #define DEBUG true
    String state,timegps;
  
    char latitude[16];// = "24";
    char longitude[16];// = "24";
    int numLatitude = 1,numLongitude = 100;
  
  
  
    void gsm_disConnect_gprs(){
    serialSIM808.write("AT+CGATT=0\r\n"); // Attach to GPRS
    delay(2000);
    Serial.println("GPRS off");
    }
  
  void setup() {
    //Begin serial comunication with Arduino and Arduino IDE (Serial Monitor)
    Serial.begin(9600);
    while(!Serial);
  
    //Being serial communication witj Arduino and SIM808
    serialSIM808.begin(9600);
    delay(1000);
  
    Serial.println("Setup Complete!");
    delay(200);
  
    sendData("AT+CGNSPWR=1",1000,DEBUG);//Turn on GPS(GNSS - Global Navigation Satellite System)
    delay(200);
    sendData("AT+CGNSSEQ=RMC",1000,DEBUG);//configure GPS sequence mode to RMC
    delay(200);
    sendData("AT+CGPSSTATUS?",1000,DEBUG);//check if GPS status is either 2D or 3D fix location. You can use this AT command to check te GPS status manually using the serial monitor.
  
  
    getGPSLocation();
  
    serialSIM808.write("AT+CREG?\r\n");
    delay(150);
    gsm_connect_gprs();
  
  }
  
  void getGPSLocation()
  {
  //--------------------- send SMS containing google map location---------------------
  sendTabData("AT+CGNSINF",1000,DEBUG);//Get GPS info(location
  if (state !=0) {
  Serial.println("State  :"+state);
  Serial.println("Time  :"+timegps);
  Serial.println("Latitude  :"+latitude);
  Serial.println("Longitude  :"+longitude);
  } else {
  Serial.println("GPS Initializing… Items to check: Power supply 12v 2A; Antenna must be facing the sky and/or near the window; Power switch must be turned on.");
  }
  //-----------------------------------------------------------------------------------
  }
  
  
  void sendTabData(String command , const int timeout , boolean debug){
  
  serialSIM808.println(command);
  long int time = millis();
  int i = 0;
  
  while((time+timeout) &gt; millis()){
  while(serialSIM808.available()){
  char c = serialSIM808.read();
  if (c != ',') {
  data[i] +=c;
  delay(100);
  } else {
  i++;
  }
  if (i == 5) {
  delay(100);
  goto exitL;
  }
  }
  }exitL:
  if (debug) {
  state = data[1];
  timegps = data[2];
  latitude = data[3];
  longitude =data[4];
  memset(data,0,sizeof(data));
  }
  }
  
  
  String sendData (String command , const int timeout ,boolean debug){
  String response = "";
  serialSIM808.println(command);
  long int time = millis();
  int i = 0;
  
  while ( (time+timeout ) &gt; millis()){
  while (serialSIM808.available()){
  char c = serialSIM808.read();
  response +=c;
  }
  }
  if (debug) {
  Serial.print(response);
  }
  return response;
  }
  
  
  void gsm_connect_gprs(){
    serialSIM808.write("AT+CGATT=1\r\n"); // Attach to GPRS
    delay(2000);
    serialSIM808.write("AT+SAPBR=1,1\r\n"); // Open a GPRS context
    delay(2000);
    //serialSIM808.write("AT+SAPBER=2,1\r\n");  // To query the GPRS context
    //delay(2000);
    Serial.println("GPRS on");
  }
  
  
  void gsm_send_data(String * latitude,String * longitude)
  {
      Serial.println("Sending data.");    
      serialSIM808.write("AT+HTTPINIT\r\n");  // Initialize HTTP
      //Serial.print("AT+HTTPINIT\r\n");
      delay(1000);
      serialSIM808.write("AT+HTTPPARA=\"URL\",\"http://499b.000webhostapp.com/?latitude=3&amp;longitude=16\"\r\n"); // Send PARA command
      //serialSIM808.write("AT+HTTPPARA=\"URL\",\"http://shehanshaman.000webhostapp.com/?id=");
      //Serial.print("AT+HTTPPARA=\"URL\",\"http://shehanshaman.000webhostapp.com/?id=");
      delay(50);
      serialSIM808.write(latitude);   // Add id to the url
      //Serial.print(latitude);
      delay(50);
      serialSIM808.write("&amp;longitude="); 
      //Serial.print("&amp;longitude=");
      delay(50);
      serialSIM808.write(longitude);   // Add value to url
      //Serial.print(longitude);
      delay(50);
      serialSIM808.write("\"\r\n");   // close url
  
      //Serial.print("\"\r\n");
      delay(2000);
      serialSIM808.write("AT+HTTPPARA=\"CID\",1\r\n");    // End the PARA
      //Serial.print("AT+HTTPPARA=\"CID\",1\r\n");
      delay(2000);
      serialSIM808.write("AT+HTTPACTION=0\r\n");
      //Serial.print("AT+HTTPACTION=0\r\n");
      delay(3000);    
      serialSIM808.write("AT+HTTPTERM\r\n");
      //Serial.print("AT+HTTPTERM\r\n");
      //Serial.println();
      delay(3000);    
      Serial.print("data sent complete : ");
  }
  
  void loop() {
    //Read SIM808 output (if available) and print it in Arduino IDE Serial Monitor
    if(numLatitude&lt;5){
      itoa(numLatitude, latitude, 10);
      itoa(numLongitude,longitude, 10);
      gsm_send_data(latitude,longitude);
      Serial.print(numLatitude);
      Serial.print(" &gt;&gt; ");
      Serial.print(numLongitude);
      Serial.println();
      delay(2000);
      numLatitude++;
      numLongitude+=45;
      if(numLatitude==5) gsm_disConnect_gprs();
    }
  
  }
  </code></pre>