×

C Tutorial

C Basics

C Data Types

C Input/Output

C Operators

C Conditional Statements

C Control Statements

C Strings

C Functions

C Arrays

C Structure and Unions

C Pointers

C Preprocessor Directives

C Command-line Arguments

C File Handlings

C Graphics

C Advance Topics

C Tips and Tricks

C Important Topics

C Practice

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




Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.