Try   HackMD

2021-04-06 yuchun1214

測驗 1

static void run(char *c, int t) { char *redir_stdin = NULL, *redir_stdout = NULL; int pipefds[2] = {0, 0}, outfd = 0; char *v[99] = {0}; char **u = &v[98]; /* end of words */ for (;;) { c--; if (is_delim(*c)) /* if NULL (start of string) or pipe: break */ break; if (!is_special(*c)) { c++; /* Copy word of regular chars into previous u */ // XXXXX /* 在此提交你的程式碼 */ /****************************/ --u; if (is_blank(*c)) *c = '\0'; while (!is_special(*--c)) *u = c; /***************************/ } if (is_redir(*c)) { /* If < or > */ if (*c == '<') redir_stdin = *u; else redir_stdout = *u; if ((u - v) != 98) u++; } } if ((u - v) == 98) /* empty input */ return;

輸出結果:

➜ quiz7 gcc picosh.c ➜ quiz7 ./a.out $ mkdir dir $ ls a.out dir http picosh.c $ echo hello world > x $ cat < x | grep hello hello world $ ls /dev | wc -l 243 $

文字訊息不要用圖片展現!
:notes: jserv

測驗 2