Created
October 5, 2014 09:49
-
-
Save nramsbottom/43bb5f74f84ef69802a9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static char *keyword; | |
| static char *args[10]; // array of pointers to the arguments (stored in command) | |
| int parse_command(char *command, char **keyword, char *args[]) { | |
| char *tmp; | |
| int n; | |
| tmp = strtok(command, " "); | |
| if (tmp != NULL) | |
| *keyword = tmp; | |
| n=0; | |
| while (tmp != NULL) { | |
| tmp = strtok(NULL, " "); | |
| args[n++] = tmp; | |
| } | |
| return n; // return the number of arguments parsed | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment