【问题标题】:How to call an executable C file from within the command line while running a different C file?如何在运行不同的 C 文件时从命令行中调用可执行的 C 文件?
【发布时间】:2018-12-11 03:41:54
【问题描述】:

我有一个可执行的创建程序,在进入时运行

./create -f pathname [linkname]

我有一个不同的 C 程序,它用作接口,需要命令行用户输入,开头没有“./”。

如何调用可执行文件“create”并让它从其他程序运行?

【问题讨论】:

    标签: c command-line interface executable


    【解决方案1】:

    您可以使用 system() 函数从 C 程序运行 bash 命令。

    #include <stdlib.h>
    
    int status_val =  system("./program2 args")
    

    【讨论】:

      猜你喜欢
      • 2017-08-30
      • 2021-12-21
      • 2023-01-30
      • 1970-01-01
      • 1970-01-01
      • 2018-06-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多