Invoking DOS commands from C++

This is a discussion on Invoking DOS commands from C++ within the C++ Programming forums, part of the General Programming Boards category; One quick question... how can I invoke some DOS commands from a C++ program ? Say I wanna do a ...

  1. #1
    Registered User
    Join Date
    Oct 2001
    Posts
    2

    Invoking DOS commands from C++

    One quick question... how can I invoke some DOS commands from a C++ program ? Say I wanna do a "dir" or call some other executable from my C++ program. Is it possible ? How ?

    Thanks.

  2. #2
    Registered User ivandn's Avatar
    Join Date
    Oct 2001
    Posts
    49
    #include <cstdlib>





    int main()


    {


    System("dir"); // i forget if it is S or s in system on windows


    return 0;


    }

  3. #3
    Skunkmeister Stoned_Coder's Avatar
    Join Date
    Aug 2001
    Posts
    2,572
    system not System
    Free the weed!! Class B to class C is not good enough!!
    And the FAQ is here :- http://faq.cprogramming.com/cgi-bin/smartfaq.cgi

  4. #4
    Registered User
    Join Date
    Oct 2001
    Posts
    2
    Thanks a lot ! That works ! But what if I wanna use the results for "dir" in my program ? Like how would I store a list of all the files and dirs in my program and then use it for some processing ?

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, 01:40 PM
  2. Dos commands hehe
    By Carp in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 01-17-2003, 02:51 PM
  3. DOS Commands
    By Zuul in forum C++ Programming
    Replies: 11
    Last Post: 01-04-2002, 04:41 PM
  4. How to run DOS commands from c++
    By ihsir in forum C++ Programming
    Replies: 2
    Last Post: 12-05-2001, 05:59 AM
  5. dos commands in c++
    By Unregistered in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 10-19-2001, 12:05 AM

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