Dos window auto-close

Posts 1–4 of 4 · Page 1 of 1
Dos window auto-close
I just started reading a book for C++ and have coded Hello World

Code:
#include <iostream.h>

int main()
{
     cout << "Hello World!\n";
     return 0;
}
So I compile it with Dev-C++ and run it, but my dos window flash closes upon executing the script.

Windows Vista 32b (your standard PC)

I can execute it through this process, but it is very lengthy and redundant:

target of CMD.exe shortcut - C:\Windows\System32\cmd.exe /k "C:\dev-cpp\library\untitled1.exe"
try this line of code before
Code:
return 0;
Code:
system("pause");
i also want to mention since you are a beginner in C, this is an ok way to see what your doing, otherwise it's not safe to use on advance projects.

http://stackoverflow.com/questions/1...hy-is-it-wrong
or

getchar();

but u need to include: #include <stdio.h>
Or you can just use:

Code:
cin.get()
once or twice, and then it waits until you press enter.
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Tags for this Thread

None

Talk with us