#include <stdio.h> #include <ctype.h> void parse_shell_input(char *line) { char first = true; while (*line) { while (*line == ' ') line++; int len = 0; while (line[len] && line[len] != ' ') len++; if (*line == 0 || *line == 127) // why is there a char 127 ?? break; if (!first) printf("\n"); printf("%.*s", len, line); first = false; line += len + 1; } } 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