Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- char **commandParser(char *command)
- {
- int i=0;
- char** paramets;
- int sizecommand=0;
- sizecommand=strlen(command);
- int numberspaces=0;
- for(i=0;i<sizecommand;i++)
- {
- numberspaces++
- }
- paramets=(char**)malloc((numberspaces+2) * sizeof(char*));
- int counter=0;
- i=0;
- int j=0,k=0,help=0;
- for(i=0; i<sizecommand;i++)
- {
- if(command[i]==' ')
- {
- paramets[k]=(char*)malloc((counter+1) * sizeof(char*));
- j=0;
- help=i-counter;
- while(help<i)
- {
- paramets[k][j]=command[help];
- j++;
- help++;
- }
- paramets[k][j]='\0';
- counter=0;
- k++;
- continue;
- }
- counter++;
- }
- paramets[k+1]=NULL;
- return paramets;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement