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


system(char *command);


    char *command = "ls";

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



Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© some rights reserved.