Thread: Execute DOS Commands in C++?

  1. #1

    Execute DOS Commands in C++?

    I'm trying to use that DOS command to output a dir result to a text file. Is there any way to execute the command through in my C++ program?

    If not, is there a way in C++ to get a list of all files in a directory?


  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Yes, there is:
    #include <stdlib.h> 
    int main (int argc, char* argv[]) 
       system("dir C:\\temp > C:\\temp\\out.txt");
       return 0;

  3. #3
    Great, thanks!

  4. #4
    Sir Mister Insane Sako Klinerr1's Avatar
    Join Date
    May 2002
    i thouhgt u need to include dos.h ? even tho it wouldnt make sense....
    Email: || AIM: MisterSako || MSN:

    -the shroom has spoken

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Executing DOS commands from inside an image
    By Moony in forum C Programming
    Replies: 6
    Last Post: 03-16-2008, 12:40 PM
  2. Replies: 2
    Last Post: 07-27-2007, 12:48 PM
  3. Dos commands hehe
    By Carp in forum A Brief History of
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM
  4. DOS Commands
    By Zuul in forum C++ Programming
    Replies: 11
    Last Post: 01-04-2002, 04:41 PM
  5. dos commands in c++
    By Unregistered in forum A Brief History of
    Replies: 1
    Last Post: 10-18-2001, 11:05 PM