How to read single char from a char array pointer

Excuse the thread subject, I don't think it properly explains what I want to do.

I'm using strtok to parse an incoming message which consists of a series of values delimited by a given character (semicolon in my case).

        char input[length];
        memcpy (input, payload, length );
        char *parts[27];
        char *ptr;
        ptr = strtok(input, ";");
        int i=0;
        while (ptr !=NULL) {
          parts[i++] = ptr;
          ptr = strtok(NULL, ";");
        }
        for (int j=1;j<9;j++) {
          weatherDay[h].temp[j-1] = atoi(parts[j]);
        }

This works well, but in some cases there may be a missing value, in which case the service that sends the message inserts an 'x' into the message, like this:

2;x;x;x;4;5;6

In this case the value written into my struct weatherDay..temp[j-1] is a zero, presumably because when the atoi function cannot interpret an 'x', so it sets it to zero.
I was hoping to amend the above as follows, so that it sets the value to 256 where there is an 'x'.
(I can assume that if the temperature is set to 256 - a nonsense value - then either there's a missing value, or the atmospheric temperature is well past boiling point, either way I won't care)
</mark> <mark>        for (int j=1;j<9;j++) {           if (parts[j] == 120) {             weatherDay[h].temp[j-1] = 256;           } else {           weatherDay[h].temp[j-1] = atoi(parts[j]);           }         }</mark> <mark>
where 120 is the ascii value of x. This doesn't compile, presumably because parts[j] is the pointer to the array?
How would I best go about doing this?

how about checking isdigit() or strstr() before you assign the atoi()?

Thanks BulldogLowell.

I understand isdigit will check for the presence of a digit, but this doesn't include a negative symbol (e.g. if the temp is -1). Because it hasn't been converted yet to integer, I don't think that will work, am I wrong?

I'm trying to figure out how to use strstr. Documentation says it returns a pointer to the first occurrence of x in y, or null pointer if it's not found. Can you give me a hint on how I might use it to check, I tried this and then understood why it didn't work:

          if (strstr(parts[j], "x")) {
            weatherDay[h].temp[j-1] = 256;
          } else {
            weatherDay[h].temp[j-1] = atoi(parts[j]);
          }

you got it, yes?

const char* parts[4] = { "123", "-123", "x", "456"};

int weather[4]= {0};
void setup() {
  Serial.begin (9600);
  for (int i = 0; i < 4; i++)
  {
    if (strstr(parts[i], "x")) 
   {
     weather[i] = 256;
   } 
   else 
   {
     weather[i] = atoi(parts[i]);
   }
 }
  for (int i = 0; i < 4; i++)
  {
    Serial.println(weather[i]);
  }
}  

void loop()
{
  
}

outputs:

123
-123
256
456

Hmm that didn't work in my version! I will go back and study your example more carefully. Many thanks!

here it is tokenizing a C string in a very contrived example:

char myMessage[] = "111!-222!x!333";

int weather[4]= {0};
void setup() 
{
  Serial.begin (9600);
  char *ptr;
  ptr = strtok(myMessage, "!");
  int i = 0;
  while(ptr != NULL)
  {
    if(!strstr(ptr, "x"))
    {
      weather[i] = atoi(ptr);
    }
    else
    {
      weather[i] = 256;
    }
    ptr = strtok(NULL, "!");
    i++;
  }
  for (int i = 0; i < 4; i++)
  {
    Serial.println(weather[i]);
  }
}  

void loop()
{
  
}