转:https://blog.csdn.net/kepp_smiling/article/details/77838637

程序:可执行文件。
进程(process):正在运行的程序,或程序的一次执行过程。
软件:程序+文档
现代操作系统都是多任务和多用户的。

在一个程序中执行另一个程序的方法
1、system函数
int system(const char* command)注意参数为常量的问题

#include<iostream>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

int main()
{
    if(-1==system("/usr/bin/poweroff"))//系统调用别的程序
    {                        //站在巨人的肩膀上开发
                            //也可以主函数传参
        perror("poweroff");
    }
    return 0;
}

2、popen将一个程序的标准输入(输出)通过管道导向到另一个程序
FILE *popen(const char *command, const char *type);
3、exec族函数
4、fork()函数

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
  • 2021-11-02
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-10-14
  • 2021-08-03
  • 2021-12-02
  • 2022-01-07
  • 2021-07-09
  • 2021-07-27
相关资源
相似解决方案