Lets say during compilation, I know I have 3 or n char *cmd[] arrays. I need to store it somewhere How do I store 3 or n char *cmd[] arrays?
Like storing lists of list in java. I could store 3 or n and then go over them in a loop as it is dynamic enough to allow me to add any number of lists to it
Sorry, I am new to c so don't quite understand pointer storage
Here's what I am trying to do:
char **cmds[len+1]; //store all command arrays
int c = 0;
int pipe_c=0;
int start = 0, end=0;
len = 3 (here)
for(int i=0; i<len; i++){ //iterate over all set of pipe arugments (x y z | x y | d)
end = pipeIndices[i]; //end index of token to copy (excluding)
char *cmd[end-start+1]; //create an array to store first set of tokens (x y z)
for(start; start<end; start++){
cmd[c++] = strdup(tokens[start]); //copy tokens from start to end
}
start = end+1; //next set of tokens
cmds[pipe_c++] = cmd; //add cmd array to cmds
}