在白色空间之间拆分char数组

时间:2013-11-05 03:14:03

标签: c++ string unix system

我正在编写一个程序,它将在UNIX中重新创建管道。用户输入一个命令,该命令存储在包含的char数组参数中,为了执行它们,我需要调用exec,但我的程序是如何将命令与参数分开,所以我可以这样做:

data in char command: ls -l
execvp("ls", <arguments>(in this case -l));

1 个答案:

答案 0 :(得分:0)

也许你需要使用strtok函数:http://www.cplusplus.com/reference/cstring/strtok/

相关问题