Home » C programming language

What is the function to execute Linux/Windows DOS commands in C language?



This is a common interview question in C programming language. Here, we are going to discuss which function is used to execute Windows DOS or Linux command in C programming language.
Submitted by IncludeHelp, on May 10, 2018

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.

Then, Which function is used to execute DOS, Linux command?

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).

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






Was this page helpful? YES NO

Are you a blogger? Join our Blogging forum.



Comments and Discussions


We are using Google to publish ads on our website; Google has its own privacy policies. They may save log, cookies on your system. Google may also collect information of your system like IP address, region, city, country. For more details please go through the Google’s privacy policy.