I was trying using strtok(), but it is giving segmentation faults. Could anyone please tell me where the problem is in the code and is there any better way to tokenize a string other than strtok() ?
void tokenize(char *tagToFind, char *record, char *delim)
{
    char *token;
    char *itr;
    char *tag;
    char *tag5;
    int toBreak=0;
    token = strtok(record,delim);
    while (token != NULL)
    {
            itr = token;
            while (*itr != '{')
            {
                    tag = itr;
                    itr++;
                    tag++;
            }
            tag = '\0';
            if ((strcmp(tag, tagToFind) == 0))
                    break;
            else
                    token = strtok(NULL,delim);
    }
    if(strcmp(tag5, "tag5") == 0)
    {
            cout<<"\n\n\n\n\t\ttag5 is present.";
    }
}
int main()
{
    char *tag = "tag5";
    char *record = "tag1{0}|tag2{0}|tag3{0}|tag4{0}|tag5{tag51{0};tag52{0};tag53{0};tag54{0};tag55{tag551{0}:tag552{0}:tag553{0}:tag554{0}:tag555{0}}}";
    char *delim = "|";
    tokenize(tag, record, delim);
    return 0;
}
 
     
     
    