Display characters in cstring upto character "|"

Hi all,

I have a cstring with data like this:
1234|54678|675844|

And I want to display all the characters upto the symbol "|" (not including the symbol "|").

I am playing around with potential solutions but have not found one yet!

Like:

 Serial.println (strstr(data1, seperator) + 1);

Any help with this would be awesome!

Thanks,

Zeb

How about a for loop iterating through the array until it finds the required character ?

How about strtok() using the required character as its delimiter ?

consider

void
setup (void)
{
    Serial.begin (115200);

    char  s [] = "1234|54678|675844|";
    char *t =  s;
    char *q;

    while (q = strtok (t, "|")) {
        Serial.println (q);
        t = NULL;
    }
}

void
loop (void)
{
}

Thanks very much! all working!