DOS question

By daedalus ยท 7 replies
Dec 15, 2003
  1. Greetings to you all. This is my first time to post, but I have been reading for a long while. Now I must come to you for help. I am learning c++ right now. I have a couple of books and i am eating this info up! I seem to have a problem that when i compile my source code, the exe it generates is doing something wierd. Well, I think its the OS, but im not sure. I click on the exe and the dos window pops up and then dissapears real fast. I was running win xp pro and thought maybe this is the no dos thing in winxp. So I tried it in 2000. No luck....I even tried it with some simple hello world code. The dos window doesnt stay up so that i can enjoy seeing my program.
  2. Spike

    Spike TS Evangelist Posts: 2,168

    Try writing a little batch file like this.

    Open notepad, and paste the following script.

    @echo off
    %1 %2 %3 %4 %5 %6 %7 %8 %9

    Save it in your windows directory as 'run.bat'

    now, try running the program from the run box on the start menu,

    eg, for a program in the windows directory called xyz.exe

    at the run box type 'run xyz.exe' and hit enter.

    The batch file 'run.bat' will hold the window open displaying the result oif running 'xyz.exe' untill you press a key.

    Hope this helps
  3. daedalus

    daedalus TS Rookie Topic Starter

    yes thank you for the fix......i had already done this....but i would rather know how to fix windows supposed to do this casue i have before gotten this to work....thnks though
  4. LNCPapa

    LNCPapa TS Special Forces Posts: 4,276   +461

    or you can try executing the exe from a dos prompt - that may display the info you want (maybe)
  5. daedalus

    daedalus TS Rookie Topic Starter

    nope....neither one worked....thnks for tryin....i tried running it in compatibility mode...and that didnt work either......
  6. Nodsu

    Nodsu TS Rookie Posts: 5,837   +6

    If you want the CLI window to remain you can do one of the following:

    1) Run command prompt, navigate to your program's directory and run your exe from the command line.

    2) Right click on your .exe file, choose properties. Under "Program" untick "Close on exit" box.

    3) At the end of your program, add a statement that waits for user input like "getch()".

    4) Make a batch file like shown above
  7. filthy_mcnasty

    filthy_mcnasty TS Rookie Posts: 78

    all of the previous posts are correct. it's not a problem with anything. that's just how it works.

    if you have tried it from a command prompt ("cmd.exe" from the start->run box) and it still closes then you've got something funky going on, probably an access violation or something but i doubt you're causing one of those in "Hello world", but maybe you are, i've seen some people do some weird things.

    anyways if that's not a viable solution *ie, if you dont always want to use the command prompt to run the program* you can use method 3 that nodsu suggested above.

    i used to always use...

    int main(){
    return 0;

    which has basically the same effect as nodsu's #3.
  8. daedalus

    daedalus TS Rookie Topic Starter worked! thanks for the info.........seems that i have learned somethng new...yay!
Topic Status:
Not open for further replies.

Similar Topics

Add your comment to this article

You need to be a member to leave a comment. Join thousands of tech enthusiasts and participate.
TechSpot Account You may also...