dos命令c语言下执行命令
Whenever we need to execute system command like DOS command or Any Linux command, we cannot send it to the operating system directly, we need a function that will accept the command in the C program and send it to the operating system to execute.
每当我们需要执行DOS命令或Any Linux命令之类的系统命令时,我们都无法将其直接发送到操作系统,我们需要一个函数来接受C程序中的命令并将其发送到操作系统以执行。
Then, Which function is used to execute DOS, Linux command?
然后 ,哪个函数用于执行DOS,Linux命令?
There is a function named system() in C programming language, which is defined in stdlib.h file. This function executes Linux Terminal Commands as well as Windows DOS Command (you must be aware the specific system commands while using this function).
C语言中有一个名为system()的函数,该函数在stdlib.h文件中定义。 该功能执行Linux终端命令以及Windows DOS命令(使用此功能时必须注意特定的系统命令)。
Syntax:
句法:
system(char *command);
Example:
例:
char *command = "ls";
system(command);
This function takes one argument which is a character pointer that contains the specified command to be executed.
此函数采用一个参数,该参数是一个字符指针,其中包含要执行的指定命令。
Read more: Executing system commands using C program
阅读更多: 使用C程序执行系统命令
翻译自: https://www.includehelp.com/c/function-to-execute-linux-windows-dos-commands.aspx
dos命令c语言下执行命令