Thread: How to Use DOS Ccommands in a C++ Program?

  1. #1
    Registered User
    Join Date
    Feb 2003
    Posts
    2

    How to Use DOS Ccommands in a C++ Program?

    How can I use DOS commands in a C++ program?

    For example, how can I do something like this from within a program:

    cd\folder
    copy *.* c:\folder2

    Thanks

  2. #2
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    you can use system():

    Code:
    #include <cstdlib>
    
    system("cd \\folder");
    system("copy *.* c:\\folder2);
    yeah? should work, might just need one \.

  3. #3
    Registered User
    Join Date
    Feb 2003
    Posts
    2
    Great, thanks.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  3. BOOKKEEPING PROGRAM, need help!
    By yabud in forum C Programming
    Replies: 3
    Last Post: 11-16-2006, 11:17 PM
  4. initialising a DOS program from a C enviroment
    By Robert_Ingleby in forum C Programming
    Replies: 5
    Last Post: 03-07-2002, 01:53 PM
  5. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM