intializing an array of strings in C

doubty's Avatar
Light Poster
Hi I have a string , out of which iam trying to extract relevant substrings. the substrings are being stored in an array of strings, now my problem is that initially i need to push the initial string as one of the elements of the array of substrings ( the original string it self), i.e in my array of substrings, the first element should be the string it self.
Aesop's Avatar
Light Poster
Could you elaborate please?
doubty's Avatar
Light Poster
HI this is my query :

I have a string A(A(c))

I have extracted all the substrings of it i.e A(A(c)),A(c),c

I have writtena recursive function to extract the substrings, and i need to store the substrings into an array of strings, Iam having issues in doing so

lets say
if(openbrac_count==closebrac_count & openbrac_count != 0)
{
strncpy(label[j][50],inputexp,i);
j++;
}
i need to store the substring into the array of strings label, please help.
Aesop's Avatar
Light Poster
If beginning is the index of the first char of inputexp that you want in the substring, and if length is the length of the substring, then
Code:
strncpy(label[j],inputexp+beginning,length);
label[j][length] = 0;
j++;