In below code , I have been facing some unusual behavior of strtol function as it doesn't return the last value associated with string passed as a 2nd parameter to the expcmp function. I don't see same behavior with first string .
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int16_t  expcmp( char* exp_cmp,char* exp_val)
{
    char DELIM='.';
    int16_t rc=1;
    char *p=NULL;
    char *temp=NULL;
    if(strlen(exp_cmp)>0)
        {
            p=(char*)malloc(sizeof(strlen(exp_cmp)+1));
            strcpy(p,exp_cmp);
            printf("p=%s\n",p);
        }
    if(strlen (exp_val)>0)
        {
            temp=(char*)malloc(sizeof(strlen(exp_val)+1));
            strcpy(temp,exp_val);
            printf("temp=%s\n",temp);
        }
    while (*temp) {
        if (isdigit(*temp)) {
            int16_t val = strtol(temp, &temp, 10);
            printf("temp=%d\n",val);
        }
        else if(*temp!=DELIM)
            {
                rc=0;
                break;
            }
        temp++;
    }
    while (*p) {
        if (isdigit(*p)) {
            int16_t val = strtol(p, &p, 10);
            printf("val=%d\n",val);
        }
        else if(*p!=DELIM)
            {
                rc=0;
                break;
            }
        p++;
    }
    return rc;
}
int main()
{
    int ret_code;
    ret_code=expcmp(".1.7.8.29.41.8153",".1.7.8.29.41.8153");
    return 0;
}
 
    