【发布时间】:2014-03-30 19:58:01
【问题描述】:
我目前在 main 中有一个 char *command[SIZE] 数组,它通过接受用户输入来填充。可以填写的示例是 {"ls", "-1", "|" “种类”}。我想将此作为函数的参数,并使用分隔符“|”将其拆分为两个数组(char *command1[SIZE]、char *command2[SIZE])。所以 char *command1[SIZE] 包含 {"ls" 和 "-l"},而 char *command2[SIZE] 包含 {"sort"}。 Command1 和 command2 不应包含分隔符。
下面是我的部分代码...
** void executePipeCommand(char *command) {
char *command1[SIZE];
char *command2[SIZE];
//split command array between the delimiter for further processing. (the delimiter
is not needed in the two new array)
}
int main(void) {
char *command[SIZE];
//take in user input...
executePipeCommand(command);
}
**
【问题讨论】: