#include <stdio.h> #include <ctype.h> void parse_shell_input(char *line) { // Your logic here int length = 0; char temp[101] = {0}; int i = 0; while (line[length] != '\0'){ if (line[length] != ' ') { temp[i] = line[length]; i++; } else { if (temp[0] != '\0') printf("%s\n",temp); for (int j=0; j <= i; j++) { temp[j] = '\0'; } i = 0; } length++; } if (temp[0] != '\0') printf("%s",temp); } 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