Compare const char * to const char Using ArduinoJson I have assigned a value such as;

const char* id = root["id"];


in the original JSON id was "1"

if (strcmp(id, "1") == 0) {
    // this executes
}


I have an array of structs that I wish to compare the id against. The struct looks like;

typedef struct  {
   char id[2];
   ....
} Device;


I assign an id (1-9) into the struct id by

_cmd.id[0] = '0' + (++DevicesPtr);
_cmd.id[1] = '\0';
Devices[DevicesPtr-1] = _cmd;


where _cmd is of type Device. Devices is an array with up to 8 entries
Now I try to find a match in the devices using the JSON id

for (byte i = 0; i &lt; DevicesPtr; i++) {
    if (strcmp(Devices[i].id, id) == 0) {
       // This code does not execute
    }
}


I can't seem to get a match I have also tried (Devices[i].id == id)
Try something like this:

typedef struct  {
  char id[2];
  ....
} Device;

const int DEVICES_MAX = 8;
Device Devices[DEVICES_MAX];

for (int i = 0; i &lt; DEVICES_MAX; i++) {
  Devices[i].id[0] = '1' + i;
  Devices[i].id[1] = 0;
  ...
}

for (int i = 0; i &lt; DEVICES_MAX; i++) {
  if (!strcmp(Devices[i].id, id)) {
  ...
}


Cheers!