I would like to understand why I needed to use malloc in this. The goal of my code was to separate "]" and ")" from ";". So like this "];" into "]" ";" and ");" into ")" ";". ptr is being used as an array of strings. I can't remember the technical name of array of strings. This works perfectly, but it save me lots of time to understand why this happened in the future. 
char  *ptr[buflen];
for(x = 0; x < n; x++)
{
    printf("ptr[x] is %s \n", ptr[x]);
    cmp_str3 = strcmp(ptr[x], "];");
    cmp_str4 = strcmp(ptr[x], ");");
    if(cmp_str3 == 0)
    {
        printf("Match1 \n");
        strcpy(str1, ptr[x]);
        printf("Match2 \n");
        ptr[x][1] = '\0';
        printf("Match3 \n");
        //printf("ptr[x+1] %c %d \n", ptr[x+1], ptr[x+1]);
        //printf("ptr[x+1][0] %c %d \n", ptr[x+1][0], ptr[x+1][0]);
        ptr[x+1] = malloc(strlen("foo") + 1);
        ptr[x+1][0] = str1[1];
        printf("Match4 \n");
        ptr[x+1][1] = '\0';
        printf("Match5 \n");
        n++;
    }
    if(cmp_str4 == 0)
    {
    }
}
cmp_str3 = 0;
cmp_str4 = 0;
memset(str1, 0, 15);
memset(str2, 0, 15);
 
    