#include #include #include // Splits a given line into "tokens" (an array of individual words). // Splits the line on space characters. // For example, when `line` is "dcc test.c -o test", the function returns // the following array of strings: // [ // "dcc", // "test.c", // "-o", // "test" // ] char **tokenize_line(char *line, int *len); int main(int argc, char *argv[]) { // TODO: Implement your code here! } // You should not need to modify or understand the following code. // You are permitted to modify these functions if you would like, however. // Given a string, removes the trailing newline (if one exists). void remove_newline(char *str) { if (str[strlen(str) - 1] == '\n') { str[strlen(str) - 1] = '\0'; } } char **tokenize_line(char *line, int *len) { remove_newline(line); char **tokens = NULL; int i = 0; for (char *token = strtok(line, " "); token != NULL; token = strtok(NULL, " ")) { tokens = realloc(tokens, (i + 1) * sizeof(char *)); tokens[i] = token; i++; } *len = i; return tokens; }