国际五大电影节:请问C里面有没有跟system函数差不多的函数

来源:百度文库 编辑:高考问答 时间:2024/05/04 19:18:30
但是能够返回system调用的程序的返回值
例如abc.exe的返回值是3
我想定义一个变量通过调用abc.exe来将它赋值为3
那为什么我运行了int a=system(abc.exe);后a结果等-1
啊 (abc.exe是顺利执行完毕的)

system 本身就可以返回调用的程序的返回值啊

RETURN VALUE
The value returned is -1 on error (e.g. fork() failed), and the return status of the command otherwise. This latter return status
is in the format specified in wait(2). Thus, the exit code of the command will be WEXITSTATUS(status). In case /bin/sh could not
be executed, the exit status will be that of a command that does exit(127).

If the value of command is NULL, system() returns non-zero if the shell is available, and zero if not.

system() does not affect the wait status of any other children.