如何从C执行bash命令?

时间:2015-04-20 23:27:27

标签: bash c gzip

有没有办法运行命令行实用程序,例如gzip,进入C应用程序?

1 个答案:

答案 0 :(得分:21)

使用system()

#include <stdlib.h>
int status = system("gzip foo");

有关如何使用它的详细信息,请参见手册页(man 3 system)。

顺便说一下,这个问题已在这里得到答案:How do I execute external program within C code in linux with arguments?

相关问题