【笔记】C语言执行Shell命令

前言

C语言执行Shell命令

C语言执行Shell命令或DOS命令

1
2
3
4
5
#include <stdlib.h>

int main() {
system("<shell>");
}

C语言执行Linux的Shell命令

<shell>:Shell命令

1
2
3
4
5
#include <unistd.h>

int main() {
system("<shell>");
}

C语言执行Windows的DOS命令

<shell>:DOS命令

1
2
3
4
5
#include <windows.h>

int main() {
system("<shell>");
}

完成

参考文献

CSDN——freed_Day