#include <stdio.h> #include <ctype.h> void parse_shell_input(char *line) { // Your logic here int i=0; while (line[i] != '\0') { /* Skip one or more spaces */ while (line[i] == ' ') i++; /* Stop at end or newline */ if (line[i] == '\0' || line[i] == '\n') break; /* Print one token */ while (line[i] != ' ' && line[i] != '\0' && line[i] != '\n') { putchar(line[i]); i++; } putchar('\n'); } } 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