EXECL VS未知参数的大小execv [英] execl vs execv with unknown argument size

查看:209
本文介绍了EXECL VS未知参数的大小execv的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是这样的:我不得不用EXECL和execv在我的项目,但问题是如果参数的大小是未知的,但道路是已知的,我应该怎么用EXECL?或者我应该使用execv每次来代替。它们之间有什么区别呢?

Here is the case: I had to use execl and execv in my project, the problem is if the argument size is unknown but the path is known, how should I use execl ? Or should I use execv everytime instead. What are the differences between them ?

例如,如果用户输入:GCC变交流-o out或在另一条线路进入-l我如何在execl的或execv执行它们LS? PS:我能找到的路径,或者用户可以输入

For example if the user enters: gcc a.c -o a.out OR in another line enters ls -l how can I execute them in execl or execv ? ps: I can find path, or the user may enter it.

另一个主要问题是,如果我有几条路径,我怎么能单独这我的命令,我应该尝试的if else情况下,他们每个人的?

Another main question is, if I got several paths, how can I seperate the correct path which my command in, should I try in if else case, each of them ?

推荐答案

您使用 EXECL 当你知道参数列表的大小,可以使用 execv 时,你必须动态地构造参数列表。

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.

这篇关于EXECL VS未知参数的大小execv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆