0

情况如下:我必须在我的项目中使用 execl 和 execv ,问题是如果参数大小未知但路径已知,我应该如何使用 execl ?或者我应该每次都使用 execv 。它们之间有什么区别?

例如,如果用户输入: gcc ac -o a.out 或在另一行输入 ls -l 我如何在 execl 或 execv 中执行它们?ps:我可以找到路径,或者用户可以输入它。

另一个主要问题是,如果我有几条路径,我怎么能分开我的命令所在的正确路径,如果其他情况,我应该尝试每一个?

4

1 回答 1

2

You use execl when you know the size of the argument list, you use execv when you have to construct the argument list dynamically.

I don't understand the second question. But you shouldn't ask two questions in one post in SO. Start another question with your second one, and explain more clearly what you're asking.

于 2012-11-22T08:09:07.520 回答