title: how to send an array of integers and chars with Paho MQTT C Client
body: <p>I am new to MQTT. my final project is to send an array that contains a UNIX-based timestamp and its timezone code and a few integer values.</p>
  <p>following Paho MQTT C Client - MQTT Client Library Encyclopedia, I come up with its code snippet:</p>
  <pre><code>#include &quot;stdio.h&quot;
  #include &quot;stdlib.h&quot;
  #include &quot;string.h&quot;
  #include &quot;MQTTClient.h&quot;
  
  #define ADDRESS     &quot;tcp://localhost:1883&quot;
  #define CLIENTID    &quot;ExampleClientPub&quot;
  #define TOPIC       &quot;testTopic&quot;
  #define PAYLOAD     &quot;220&quot;
  #define QOS         0
  #define TIMEOUT     10000L
  
  int main(int argc, char* argv[])
  {
      MQTTClient client;
      MQTTClient_connectOptions conn_opts = MQTTClient_connectOptions_initializer;
      MQTTClient_message pubmsg = MQTTClient_message_initializer;
      MQTTClient_deliveryToken token;
      int rc;
  
      MQTTClient_create(&amp;client, ADDRESS, CLIENTID,
          MQTTCLIENT_PERSISTENCE_NONE, NULL);
      conn_opts.keepAliveInterval = 20;
      conn_opts.cleansession = 1;
  
      if ((rc = MQTTClient_connect(client, &amp;conn_opts)) != MQTTCLIENT_SUCCESS)
      {
          printf(&quot;Failed to connect, return code %d\n&quot;, rc);
          exit(-1);
      }
      int arr [3] = {1, 2, 3};
      pubmsg.payload = arr; // PAYLOAD;
      pubmsg.payloadlen = strlen(PAYLOAD);
      pubmsg.qos = QOS;
      pubmsg.retained = 0;
  
      // while(1){
              
          MQTTClient_publishMessage(client, TOPIC, &amp;pubmsg, &amp;token);
      // }
  
      printf(&quot;Waiting for up to %d seconds for publication of %s\n&quot;
              &quot;on topic %s for client with ClientID: %s\n&quot;,
              (int)(TIMEOUT/1000), PAYLOAD, TOPIC, CLIENTID);
      rc = MQTTClient_waitForCompletion(client, token, TIMEOUT);
      printf(&quot;Message with delivery token %d delivered\n&quot;, token);
      MQTTClient_disconnect(client, 10000);
      MQTTClient_destroy(&amp;client);
      return rc;
  }
  </code></pre>
  <p>I changed its payload with an array (for example with only int values). but when I publish the msg, I get an undefined character on the subscriber side:</p>
  <pre><code>testClient1@localhost&gt; sub -t testTopic -s
  &quot;
  </code></pre>
  <p>can someone please tell me how can I send that array?</p>