win xp dos?

Status
Not open for further replies.

scopexmoh

Posts: 19   +0
hello....i am starting to learn to program in c++ and have a small question...it 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 folder..is this a result of the dos change in win xp? is there anyway i can get these boxes to not automaticlly close?
 
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
 
is that at the end of the source code.....? or after the command?? explain please.....thanks for your help!
 
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
 
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?
 
Status
Not open for further replies.
Back