#include <stdio.h> #include <ctype.h> #include<string.h> void parse_shell_input(char *line) { // Your logic here char word[100]; int word_idx = 0; while (*line != '\0') { if (*line == ' ') { if (word_idx > 0) { word[word_idx] = '\0'; printf("%s\n", word); word_idx = 0; } } else { word[word_idx++] = *line; } line++; } if (word_idx > 0) { word[word_idx] = '\0'; printf("%s\n", word); } } int main() { char line[101]; fgets(line, sizeof(line), stdin); parse_shell_input(line); return 0; }
Test Cases
Test Results
Input
led set 3 on
Expected Output