title: Trying to gather the environment variables of my linux envrionment, but I keep getting segmentation faults
body: <p>Trying to print the environment variables, store them onto tokens, place said tokens into an array and then sort them with bubble sort.
  So far, I cannot put them onto an array without experiencing a segmentation fault</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  #define MAX 100
  #define MIN 5
  
  
  int main(int argc, char *argv[], char *envp[])
  {
  int i = 0;
  
  char *delimiter;
  
  delimiter= ".:;";
  
  char *token;
  
  char *tokenArray[50];
  
  
  while(envp[i])
  {
          //token = malloc(20*sizeof(char));
          token = strtok(envp[i], delimiter);
          printf(" %s \n", token);
          token = strtok(NULL, delimiter);
          tokenArray[i] = malloc(50);
          strcpy(tokenArray[i], token);
          //free(token);
          i++;
  
  }
  
  for(int j = 0; j &lt; i; j++)
  {
  
  printf(" %s \n ", tokenArray[j]);
          free(tokenArray[j]);
  }
  return 0;
  }
  </code></pre>