Executıng Commands In a Program

This is a discussion on Executıng Commands In a Program within the C Programming forums, part of the General Programming Boards category; hi ı want to execute some DOS commands wıthın my program. ıs ıt possıble...

  1. #1
    esler
    Guest

    Question Executıng Commands In a Program

    hi
    ı want to execute some DOS commands wıthın my program.
    ıs ıt possıble

  2. #2
    Registered User
    Join Date
    Sep 2001
    Posts
    4

    Cool

    Read dos.h in the help or index... Maybe it might help u.

    blueXrogue

  3. #3
    Registered User
    Join Date
    Sep 2001
    Location
    Australia
    Posts
    212
    Yes it is possible. In the ANSI/ISO C standard there is a header file called <stdlib.h> include it then use a function called system();
    Heres an example.

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

    int main(int argc, char *argv[]){
    system("cls"); // Clears the Screen
    system("copy file1 file2"); // Copy file
    system("del file1"); delete original file
    return 1;
    }

    all OS system commands can be use. BE WARNED they are not likely to be portable programs because the are OS dependent.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  2. Can someome help me with a program please?
    By WinterInChicago in forum C++ Programming
    Replies: 3
    Last Post: 09-21-2006, 11:58 PM
  3. Need help with my program...
    By Noah in forum C Programming
    Replies: 2
    Last Post: 03-11-2006, 07:49 PM
  4. Executing OS Commands via my C# Program
    By gozlan in forum C# Programming
    Replies: 2
    Last Post: 07-05-2003, 02:30 AM
  5. My program, anyhelp
    By @licomb in forum C Programming
    Replies: 14
    Last Post: 08-14-2001, 11:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21