Thread: C++ on DOS

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2003
    Location
    Brussels
    Posts
    3
    Rep Power
    0

    C++ on DOS


    I have a file on c:\2.txt
    Everything is OK with my command line
    C:\>2.txt
    I can also compile my file ex1.cpp :
    #include <stdio.h>
    #include <dos.h>
    #include <stdlib.h>
    main(){

    system("2.txt");

    }

    C:\>bcc ex1.cpp //OK I have got ex1.exe

    But when I try to do

    C:\>ex1

    I have a massage
    Bad command or file name.

    There is no problem when I do the same thing with a file ex2.cpp
    #include <stdio.h>
    #include <dos.h>
    #include <stdlib.h>
    main(){

    system("time");

    }
    C:\>bcc ex2.cpp //OK I have got ex2.exe
    C:\>ex2 // No problem and I can read a time

    If someone can help me?
    pomogu@hotmail.com
  2. #2
  3. I'm Baaaaaaack!
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Jul 2003
    Location
    Maryland
    Posts
    5,538
    Rep Power
    244
    The system command is looking for an executable. What is the chance that '2.txt' is an executable?

    My blog, The Fount of Useless Information http://sol-biotech.com/wordpress/
    Free code: http://sol-biotech.com/code/.
    Secure Programming: http://sol-biotech.com/code/SecProgFAQ.html.
    Performance Programming: http://sol-biotech.com/code/PerformanceProgramming.html.
    LinkedIn Profile: http://www.linkedin.com/in/keithoxenrider

    It is not that old programmers are any smarter or code better, it is just that they have made the same stupid mistake so many times that it is second nature to fix it.
    --Me, I just made it up

    The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man.
    --George Bernard Shaw
  4. #3
  5. Don't fear the penguins!
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2003
    Location
    arborlon.gingle.net
    Posts
    147
    Rep Power
    12
    If your trying to do somthing like launch edit and load 2.txt, try this:

    System("type 2.txt");

    This should cause the contents of 2.txt to appear on screen. You could also use edit to do much the same thing.

    (note: I've never done it before, but I think it ought to work)
    Every morning, I get up and look through the Forbes list of the richest people in America. If I'm not there, I go to work.

    May your Tongue stick to the Roof of your Mouth with the Force of a Thousand Caramels.

    To the systems programmer, users and applications serve only to provide a test load.

IMN logo majestic logo threadwatch logo seochat tools logo