#include <stdio.h> #include <ctype.h> void parse_shell_input(char *line) { int i = 0,flag = 0; while (line[i] != 0){//add newline also if(line[i] == ' '){ if(flag == 0){ printf("\n"); } flag = 1; } else{ printf("%c",line[i]); flag = 0; } i++; } //end with new line } 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