Arduino serial output going crazy

I’m trying to split a char* using strtok. This is the code:

#include <string.h>

char** splitValues;
char* to_split;
int times = 0;
int counter;

void setup() {
  Serial.begin(9600);
}

void loop() {
  to_split = "00;11;22;33;44;55";
  if(times == 0){
    counter = 0;
    for(char* temp = strtok(to_split, ";"); temp != NULL; temp = strtok(NULL, ";")){
      Serial.println(temp);
//      splitValues[counter] = temp;
//      counter++;
    }
    times = 1;
  }
}

This is working fine and outputs all the string split by “;”

But if I add the two commented rows, the program goes in loop and keeps printing the first value of temp.

I don’t understand how these two rows can loop the program.

Post the complete code. Or at least a complete example that compiles and exhibits the problem. When a piece of code doesn't work despite looking right, you gotta start looking at the rest of the code.

Sorry, I edited the post.
I didn't post the full code because it's quite longer than this, but trying to compile this example does exactly the same thing my code does.

Looks like splitValues is a pointer to a pointer that is pointing into nowhere.

char** splitValues;

splitValues is just a pointer to a pointer that is pointing to nowhere. There isn't any memory reserved to put anything anywhere from this.

And yet:

splitValues[counter] = temp;

You try to put something there. So this writes over some unknown bit of memory out of bounds and causes undefined behavior.

Instead, splitValues should be defined as an array large enough to hold whatever you want to put there.

char* splitValues[NumberOfTokensYouExpect];

Delta_G:
char** splitValues;

splitValues is just a pointer to a pointer that is pointing to nowhere. There isn't any memory reserved to put anything anywhere from this.

And yet:
splitValues[counter] = temp;

You try to put something there. So this writes over some unknown bit of memory out of bounds and causes undefined behavior.

Instead, splitValues should be defined as an array large enough to hold whatever you want to put there.

char* splitValues[NumberOfTokensYouExpect];

Thank you, this solved my problem.
Now my question is: what should I do if I need to change the size of this vector during runtime after the vector was declared?

Deazard:
Now my question is: what should I do if I need to change the size of this vector during runtime after the vector was declared?

You're working on a microcontroller, not a PC. You have to account for every scrap of memory that your code might even use. Make the array large enough to hold the largest number of tokens you think you might ever get. If you don't reserve that memory up front then when the situation arises where it needs to be bigger there may not be anymore memory to give it. Dynamic memory allocation on a microcontroller is of limited usefulness and is something not to be done by the faint of heart.