在C语言中调用Linux Shell命令

2018-01-26  本文已影响12人  louyang
# cat a.c
#include <stdlib.h>

int main()
{
   system("pwd");
}
# pwd
/opt2/foo/execte-shell-by-c

# # gcc a.c && ./a.out
/opt2/foo/execte-shell-by-c

参考
https://stackoverflow.com/questions/19209141/how-do-i-execute-a-shell-built-in-command-with-a-c-function

上一篇下一篇

猜你喜欢

热点阅读