作者
QQ群:852283276
微信:arm80x86
微信公众号:青儿创客基地
B站:主页 https://space.bilibili.com/208826118
参考
Linux系统下C语言和shell命令之间的交互
Linux下C语言 system函数返回值
linux C编程–popen函数详解
linux下C和shell调用的popen函数
方法
system
int system(constchar*command);
判断ystem函数是否正常结束,3个条件同时成立,
-1 != status
WIFEXITED(status) == true
0 == WEXITSTATUS(status)
popen
#include < stdio.h >
FILE *popen(const char *command, const char *type);
int pclose(FILE *stream);
通过 fgets/fputs/fread/fwrite/fscanf/fprintf
等函数来获取命令的输入输出。