All submissions

Implement a Simple Shell Command Parser

Code

#include <stdio.h>
#include <ctype.h>

void parse_shell_input(char *line) {
    int check_prev_space = 0;

    while (*line == ' ') line++;

    while(*line){
        if (*line == ' ' && check_prev_space == 0) 
            printf("\n");
            while (*line == ' ') line++;
        printf("%c", *line);
        line++;
    }
}

int main() {
    char line[101];
    fgets(line, sizeof(line), stdin);

    parse_shell_input(line);
    return 0;
}

Solving Approach

 

 

 

Loading...

Input

led set 3 on

Expected Output

led set 3 on