I need some ideas for dealing with array of strings. ptr contains my array of strings. The goal here is to combine certain strings when the conditions of the for loop are met. The problem is I need remove the strings that get combined with another string so I don't reuse that string later on.

The ways I thought of so far.
1. Create a temporary string array(array of char null terminated). Then combine them into the temporary string array. Then copy the temporary string array into the array of strings. After this I need to remove the the strings that got combined. The only way I can of doing this is to shift everything to the appropriate location to overwrite the strings I want to remove. I could be combining up to 5 strings at a time so I think this could be tricky.

  1. Create another array of strings. Copy the data from the original array of strings into the new array of strings as I increment through the for loop. When I need to combine strings copy them into the temporary string array. Then copy the temporary string array into the new array of strings. This way seems safer.

Is there a better way to do this? I really don't like either method.

for(x = 0; x < n; x++)
{
    if(isdigit(ptr[x][0]))
    {
        printf("ptr[x] is %s \n", ptr[x]);
        x++;
        if(ptr[x][0] == 46)
        {
            printf("ptr[x] is %s \n", ptr[x]);
            x++;
            if(isdigit(ptr[x][0]))
            {
                printf("ptr[x] is %s \n", ptr[x]);
                printf("You have a float \n");
                x++;
                if(ptr[x][0] == 69)
                {
                    printf("ptr[x] is %s \n", ptr[x]);
                    printf("You have a E \n");
                    x++;
                    if(isdigit(ptr[x][0]))
                    {
                        printf("ptr[x] is %s \n", ptr[x]);
                        printf("You have a 1.23E11 \n");
                        x++;
                    }
                    if(ptr[x][0] == '+' || ptr[x][0] == '-')
                    {
                        printf("ptr[x] is %s \n", ptr[x]);
                        printf("You have a + or - \n");
                        x++;
                        if(isdigit(ptr[x][0]))
                        {
                            printf("ptr[x] is %s \n", ptr[x]);
                            printf("You have a 1.23E-11 \n");
                            x++;
                        }
                    }
                }
            }
        }
    }
}
This article has been dead for over six months. Start a new discussion instead.