Due: Monday 11/15 8:00 am
GitHub Submission Link: git@github.com:mks65/15_parse-args.git
Write a function that uses strep to parse a line of arguments
- First off, head over to the exec and strsep section of the notes page.
- Use the following header:
char ** parse_args( char * line );
- It should take a string with the command line invocation of a program (like
"ls -a -l"
) - Note that there is a
" "
between each argument - Return an array of pointers to each individual argument in the parameter string, that could be used for
execvp()
- For example, the following code should work (assuming all variables are declared appropriately:
char ** args = parse_args( line ); execvp(args[0], args);
- To test this function, your program should use it on a string and then call
execvp
successfully. - You can make the following assumptions:
- There is only 1 space between each argument in the original string
- The original string contains no more than 5 arguments
- The original string is correctly formatted