#include <stdio.h> #include <ctype.h> void parse_shell_input(char *line) { // Your logic here int i=0, j=0, k=0; char arr[5][10]; int count = 1; while(line[i]!='\0'){ if(line[i]==' ' && line[i+1]==' '){ } else if(line[i]==' '){ arr[j][k] = '\0'; count++; k=0; j++; } else{ arr[j][k] = line[i]; k++; } i++; } arr[j][k] = '\0'; for(int p=0;p<count;p++){ printf("%s\n",arr[p]); } } 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