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