#include <stdio.h>
#include <ctype.h>
void parse_shell_input(char *line) {
// Your logic here
char word[10]="";
int i=0;
int count=0;
while(line[i]!='\0'){
if (line[i] != ' ' && line[i] != '\n') {
word[count++] = line[i];
}
else {
if (count > 0) {
word[count] = '\0';
printf("%s\n", word);
count = 0; // reset word
}
}
i++;
}
if (count > 0) {
word[count] = '\0';
printf("%s\n", word);
}
}
int main() {
char line[101];
fgets(line, sizeof(line), stdin);
parse_shell_input(line);
return 0;
}
Input
led set 3 on
Expected Output
led set 3 on