explode function for strings in arduino

Hello guys !!

Iam trying to to split a string like explode function in php using arduino but i can't find a way :(

My string is the following : String str = "26.90-59.30/30.90-60.30/25.40-69.30";

I found the strtok() function but i don't know how to use it with strings.

tkanks in advance for any help or guidance.

Hello,

Use a char array instead of a String object.

HafsaEN: Hello guys !!

Iam trying to to split a string like explode function in php using arduino but i can't find a way :(

My string is the following :

String str = "26.90-59.30/30.90-60.30/25.40-69.30";

I found the strtok() function but i don't know how to use it with strings.

tkanks in advance for any help or guidance.

The strtok() function is to be used with nullterminated strings and not with "String" objects.

char str[] = "26.90-59.30/30.90-60.30/25.40-69.30";

ok thanks :) it worked but still a problem while displaying, this is what i got :

"26.90-59.30-60.30-69.30" into tokens: 26.90 59 30 60 30 69 30

Here's my code for spliting with strtok() :

char str[] ="26.90-59.30-60.30-69.30";
  char * pch;
  printf ("Splitting string \"%s\" into tokens:\n",str);
  pch = strtok (str,"-");
  while (pch != NULL)
  {
    printf ("%s\n",pch);
    delay(1000);
    pch = strtok (NULL, " ,.-");
  }

now it looks fine :D thank you all

the problem was with this line i forgot to edit it

    pch = strtok (NULL, "-");