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