I'm writing a program in C and I can't find out how to do the following. I have two NULL terminated arrays of pointers to strings, namely
char *tokens1[size1]
char *tokens2[size2]
I want to merge them into a third array of pointers to strings, namely
char **tokens;
I've tried the following but it doesn't work:
char *tokens1[size1]
char *tokens2[size2]
char **tokens;
/* code to fill the *tokens1[] and *tokens2[] arrays with string values */
tokens = (char*) malloc(size1+size2+1);
strcpy(tokens, tokens1);
strcat(tokens, tokens2);
Could you please help me?