c语言system.h头文件下载,求system.h这个C语言头文件.

这篇博客分享了C语言中system()函数的源代码,用于将命令传递给shell执行。当command参数为NULL时,该函数会检查命令处理器是否存在。通过环境变量COMSPEC找到命令处理器,如cmd.exe或command.com。文章详细解释了函数的入口、出口条件以及异常处理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

/***

*system.c - pass a command line to the shell

*

* Copyright (c) 1985-1997, Microsoft Corporation. All rights reserved.

*

*Purpose:

* defines system() - passes a command to the shell

*

*******************************************************************************/

#include

#include

#include

#include

#include

#include

#include

/***

*int system(command) - send the command line to a shell

*

*Purpose:

* Executes a shell and passes the command line to it.

* If command is NULL, determine if a command processor exists.

* The command processor is described by the environment variable

* COMSPEC. If that environment variable does not exist, try the

* name "cmd.exe" for Windows NT and "command.com" for Windows '95.

*

*Entry:

* char *command - command to pass to the shell (if NULL, just determine

* if command processor exists)

*

*Exit:

* if command != NULL returns status of the shell

* if command == NULL returns non-zero if CP exists, zero if CP doesn't exist

*

*Exceptions:

*

*******************************************************************************/

int __cdecl _tsystem (

const _TSCHAR *command

)

{

int catch;

_TSCHAR *argv[4];

argv[0] = _tgetenv(_T("COMSPEC"));

/*

* If command == NULL, return true IFF %COMSPEC%

* is set AND the file it points to exists.

*/

if (command == NULL) {

return argv[0] == NULL ? 0 : (!_taccess(argv[0],0));

}

_ASSERTE(*command != _T('\0'));

argv[1] = _T("/c");

argv[2] = (_TSCHAR *) command;

argv[3] = NULL;

/* If there is a COMSPEC defined, try spawning the shell */

if (argv[0]) /* Do not try to spawn the null string */

if ((catch = _tspawnve(_P_WAIT,argv[0],argv,NULL)) != -1

|| (errno != ENOENT && errno != EACCES))

return(catch);

/* No COMSPEC so set argv[0] to what COMSPEC should be. */

argv[0] = ( _osver & 0x8000 ) ? _T("command.com") : _T("cmd.exe");

/* Let the _spawnvpe routine do the path search and spawn. */

return(_tspawnvpe(_P_WAIT,argv[0],argv,NULL));

}

标准库源代码里的system.c不知道你是不是找这个

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值