Is strtok for parsing my char string what I should use?

The aim is to get the names and integers from this string and store them for use as variables, but I am confused as to how go about it, I've gotten so far as it just prints out the results, but I don't know what to do next. Heres my code:

String parseString = "value1=123&value2=123&value3=123";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  parsePlease();
  delay(5000);
}

void parsePlease() {

  char parseThis[parseString.length()];
  parseString.toCharArray(parseThis, parseString.length());
  
  char *ptr = strtok(parseThis, "=&");
  while (ptr != NULL)
  {
    Serial.println(ptr);
    ptr = strtok(NULL, "=&");
  }
}

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. This can happen after the program has been running perfectly for some time. Just use cstrings - char arrays terminated with '\0' (NULL).

If you create the item as a cstring - like this

char parseString = "value1=123&value2=123&value3=123";

then you can use strtok() to parse it.

The parse example in Serial Input Basics illustrates the use of strtok()

...R

but when I use

char parseString[] = "value1=123&value2=123&value3=123";

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
}

void loop() {
  parsePlease();
  delay(5000);
}

void parsePlease() {

  //char parseThis[parseString.length()];
  //parseString.toCharArray(parseThis, parseString.length());
  
  char *ptr = strtok(parseString, "=&");
  while (ptr != NULL)
  {
    Serial.println(ptr);
    ptr = strtok(NULL, "=&");
  }
}

it only returns value1 and nothing else, why?
I'll go to the links, thanks !

The code should work, in your while loop try to add Serial.flush() or 50ms of delay after Serial.println. Depending on where you get the "parseString" from it could be better to parse it during reading (eg. from Serial).

Byte3:
it only returns value1 and nothing else, why?
I'll go to the links, thanks !

Please study the code in the link I gave you.

...R