我如何在另一个下执行C程序。假设您有一个C代码(程序),并且您想调用另一个C代码,因为您要将输入发送到它,然后将其返回数据与比较另一个预期返回数据进行评分。

例子:

 FILE try. c 

 int main  ( void ) 
   {
    for i = 0 ;  i < MAX ; ++i 
       call another program ( namely, try2.c ) to give it a single input 
       then measure its returning data
 return 0;
}

try2.c居住在另一个文件中

编译器是GCC,在系统Linux下,

有帮助吗?

解决方案

system, popen 或平台依赖诸如 forkexec

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top