title: How to transform a block of strings to an array of strings
body: <p>I've got a block of strings, say "aaa\0bbbb\0ccccccc\0"
  and I want to turn them into an array of strings.
  I've tried to do so using the following code:</p>
  
  <pre><code>void parsePath(char* pathString){
    char *pathS = malloc(strlen(pathString));
    strcpy(pathS, pathString);
    printf(1,"33333\n");
    pathCount = 0;
    int i,charIndex;
    printf(1,"44444\n");
    for(i=0; i&lt;strlen(pathString) ; i++){
        if(pathS[i]=='\0')
        {
         char* ith = malloc(charIndex);
         strcpy(ith,pathS+i-charIndex);
         printf(1,"parsed string %s\n",ith);
         exportPathList[pathCount] = ith;
         pathCount++;
         charIndex=0;
        }
        else{
          charIndex++;
        }
    }
  
    return;
  }
  </code></pre>
  
  <p>exportPathList is a global variable defined earlier in the code by
      char*  exportPathList[32]; 
  when using that function  exportPathList[i] contains garbage.
  What am I doing wrong?</p>