So I'm starting C++ and I have a problem. When I try to open the program, it automatically closes so what should I put to stop this? I tried doing a few stuff but why don't you try to help
"1: #include %26lt;iostream.h%26gt;
2:
3: int main()
4: {
5: cout %26lt;%26lt; "Hello World!\n";
6: return 0; "
Help.
How to Prevent a program by C++ from closing right away?
before return use getch();
and dont forget to add
#include %26lt;conio.h%26gt;
at the top of the program
Reply:this works
#include %26lt;iostream.h%26gt;
#include %26lt;conio.h%26gt;
int main()
{
cout %26lt;%26lt; "Hello World!\n";
getch();
return 0;
}
getch() will wait for and input just when you press any key then program will finish
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment