Thread: opening a file in dos

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    43

    opening a file in dos

    how do you make dos open a seperate file like ms paint for example

  2. #2
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    The simplest way without knowing what exec-type functions your compiler supports would be
    Code:
    system ( "mspaint" );
    My best code is written with the delete key.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    43
    what would be the whole program code for that?

  4. #4
    Registered User major_small's Avatar
    Join Date
    May 2003
    Posts
    2,787
    Code:
    ...
    #include <cstdlib>
    ...
    int main()
    {
       ...
       system("[enter system call here]");
       ...
    }
    Join is in our Unofficial Cprog IRC channel
    Server: irc.phoenixradio.org
    Channel: #Tech


    Team Cprog Folding@Home: Team #43476
    Download it Here
    Detailed Stats Here
    More Detailed Stats
    52 Members so far, are YOU a member?
    Current team score: 1223226 (ranked 374 of 45152)

    The CBoard team is doing better than 99.16% of the other teams
    Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)

    Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT

  5. #5
    Registered User
    Join Date
    Nov 2003
    Posts
    168
    He okay i'm a newb let me tell you that. Anyway, i find this a very unclear question. Open in dos?
    C:\map\map\program.exe

    c.c
    -Felix
    Rots Soft
    If the facts don't fit the theory, change the facts.
    Albert Einstein (1879 - 1955)

  6. #6
    Me -=SoKrA=-'s Avatar
    Join Date
    Oct 2002
    Location
    Europe
    Posts
    448
    That would be
    Code:
    <cstdlib>
    using namespace std;
    
    int main()
    {
      system("C:\\map\\map\\program.exe");
    
     return 0;
    }
    Note the escaping(sp?) of the backslash. I think a forward slash will work too, but I'm not sure.

    http://faq.cprogramming.com/cgi-bin/...&id=1043284392

    check out option 1
    SoKrA-BTS "Judge not the program I made, but the one I've yet to code"
    I say what I say, I mean what I mean.
    IDE: emacs + make + gcc and proud of it.

  7. #7
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    If you are in pure DOS or a DOS session (NOT available in XP) then you can call DOS int 21h and open a file via DOS or you can execute a dos interrupt from C which will automatically call DOS for you.

    DOS has specific functions for opening child processes although they are somehwhat limited since it was never designed to be a multi-tasking OS.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. File Writing Problem
    By polskash in forum C Programming
    Replies: 3
    Last Post: 02-13-2009, 10:47 AM
  2. opening empty file causes access violation
    By trevordunstan in forum C Programming
    Replies: 10
    Last Post: 10-21-2008, 11:19 PM
  3. archive format
    By Nor in forum A Brief History of Cprogramming.com
    Replies: 0
    Last Post: 08-05-2003, 07:01 PM
  4. opening a file in DOS
    By alanair23 in forum A Brief History of Cprogramming.com
    Replies: 10
    Last Post: 12-19-2002, 09:02 PM
  5. System
    By drdroid in forum C++ Programming
    Replies: 3
    Last Post: 06-28-2002, 10:12 PM