#include <stdio.h>
#include <ctype.h>
void parse_shell_input(char *line) {
// Your logic here
int i = 0;
char token[101];
int j = 0;
while (line[i] != '\0')
{
/* Skip whitespace characters */
while (isspace(line[i]))
{
i++;
}
/* Collect a word */
j = 0;
while (line[i] != '\0' && !isspace(line[i]))
{
token[j++] = line[i++];
}
/* Print token if valid */
if (j > 0)
{
token[j] = '\0';
printf("%s
", token);
}
}
}
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