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

This is a discussion on How to Use DOS Ccommands in a C++ Program? within the C++ Programming forums, part of the General Programming Boards category; How can I use DOS commands in a C++ program? For example, how can I do something like this from ...

  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, 02: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, 10: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, 12: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, 12:42 PM

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