Use the system() function to execute system command - C Function

C examples for Function:Utility Function

Description

Use the system() function to execute system command

Demo Code

#include <stdio.h>
#include <stdlib.h>

int main( void )
{
    char input[40];

    while (1){/*from   w  ww. ja v  a 2 s .c  om*/
        puts("\nInput the desired system command, blank to exit");
        gets_s(input);

        /* Exit if a blank line was entered. */
        if (input[0] == '\0')
            exit(0);

        /* Execute the command. */

        system(input);
    }
    return 0;
}

Related Tutorials