c语言调用exe并传递参数,如何使用execlp将命令行参数传递给C程序

This page包括大量的使用示例....

编辑:从链接 从链路的代码段添加的代码片段上方

static void show_info_page(const char *git_cmd)

{

const char *page = cmd_to_page(git_cmd);

setenv("INFOPATH", system_path(GIT_INFO_PATH), 1);

execlp("info", "info", "gitman", page, (char *)NULL);

die(_("no info viewer handled the request"));

}

编辑:execlp的补充说明(3)来回MTHE手册页 FreeBSD的手册页说明)execlp的使用(如下

int

execlp(const char *file, const char *arg, ... /*, (char *)0 */);

The initial argument for these functions is the pathname of a file which

is to be executed.

The const char *arg and subsequent ellipses in the execl(), execlp(), and

execle() functions can be thought of as arg0, arg1, ..., argn. Together

they describe a list of one or more pointers to null-terminated strings

that represent the argument list available to the executed program. The

first argument, by convention, should point to the file name associated

with the file being executed. The list of arguments must be terminated

by a NULL pointer.

The functions execlp(), execvp(), and execvP() will duplicate the actions

of the shell in searching for an executable file if the specified file

name does not contain a slash ``/'' character. For execlp() and

execvp(), search path is the path specified in the environment by

``PATH'' variable. If this variable is not specified, the default path

is set according to the _PATH_DEFPATH definition in , which is

set to ``/usr/bin:/bin''

PS:一些信息,如默认的搜索路径,垫变化根据您的系统

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值