Tech Stocking Stuffers: 18 awesome gifts under $50

win xp dos?

By scopexmoh ยท 4 replies
Oct 18, 2003
  1. hello....i am starting to learn to program in c++ and have a small seems that when i write a simple program, such as the hello world.....i dont have time to see the message when running the program....the dos window pops up and then closes really fast....i also noticed this when tryin to run dos commands from the sys32 this a result of the dos change in win xp? is there anyway i can get these boxes to not automaticlly close?
  2. Didou

    Didou Bowtie extraordinair! Posts: 4,274

    The reason it closes so fast is because the system opens a command prompt, exectutes the program & exits straight away. If you want to see you programs output, at the end of the intructions, add a getch();.

    That way, the programm will wait for you to hit a key on the keyboard before exiting.

    If you want to launch a command prompt from which to execute your programs, got to Start Menu -> Run -> cmd
  3. scopexmoh

    scopexmoh TS Rookie Topic Starter Posts: 19

    is that at the end of the source code.....? or after the command?? explain please.....thanks for your help!
  4. Didou

    Didou Bowtie extraordinair! Posts: 4,274

    Like this :

    #include "stdafx.h"
    #include "conio.h" //required to use getch()

    int main(int argc, char* argv[])
    printf("Hello World!\n");
    getch(); //this is where you add it
    return 0;

    PS This was done on MSVC 6
  5. scopexmoh

    scopexmoh TS Rookie Topic Starter Posts: 19

    o ok ....well thats a pain......o well.....that was never explained in my c course...any one know of a good up to date online c training or tuts?
Topic Status:
Not open for further replies.

Similar Topics

Add New Comment

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