如何从C执行bash命令?

前端之家收集整理的这篇文章主要介绍了如何从C执行bash命令?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这个问题在这里已经有一个答案:> How to execute a shell script from C in Linux?6
有没有办法运行命令行实用程序,例如gzip,进入C应用程序?

解决方法

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

有关如何使用它的更多详细信息,请参阅手册页(man 3系统).

顺便问一下,这个问题已经有了答案:How do I execute external program within C code in linux with arguments?

原文链接:https://www.f2er.com/c/111273.html

猜你在找的C&C++相关文章