separating line of arrays into array of arrays
If anyone can help -much appreciate
I want to take a line of input from the user using an array of cmd[100]; then take that input and separating them out with spaces as a delimiter into an array of arrays cmdarg[][].
I think the code below does separate them out, but for some reason i can't cout anything other than cmdarg[0]. Nothing else comes out???
this will be use as a command line with arguments in a program, but i am having a tough time separating the commands and arguments into its own vector of arrays. Is better to do it with strings??? I am not sure of what to use?
thanks in advance
//partial codes
char *c[1000];
char cmd[100];
char cmdarg[1000][1000];
int status,i=0,j=0,k=0;
cin.ignore();
cout<<"Commands:";
cin.getline(cmd,100);
for(i=0;i<100;i++){
if(cmd[i]==' '){//space
j++; //increase row
k==-1;//reset column
}
if(cmd[i]!=' '){//put in next column
cmdarg[j][k]=cmd[i];//insert in array of arrays
}
k++;//increase column
}