my hello world program closes right after it opens
| alexcook (9) | |||
| hi i am new to c++ and i just installed it yesterday but i did not get much time to use it.i just put a hello world program in it with dev c++ but once i started it, it closed very fast. this is probaly a noob problem but thanks anyways #include <iostream> using namespace std; int main () { cout << "Hello World!"; return 0; } | |||
| Nandor (83) | |||
try to put this at the end:
I use this in my console apps. Or try to start your app from Command Promt | |||
| alexcook (9) | |||
| i put it before the return 0; and it did not work, did you mean for me to put it somewhere else? | |||
| matanuragi (22) | |||
| dear sir, kindly try this #include <iostream> #include<conio> void main () { cout << "Hello World!"; getch(); } regards matanuragi | |||
| alexcook (9) | |||
| no it did not work but thank you anyways | |||
| alexcook (9) | |||
| i found something that works | |||
| QWERTYman (255) | |||
<conio.h> is a library that is only included in a Borland compiler. Try:
| |||
| tombert (10) | |||
| If you're on windows, you can use a nice little system("pause"); command. Not really portable though. | |||
| strongfan (5) | |||||
the system("Pause") command displays that annoying "Press ENTER to continue..." thing. Try using cin.get(); right before the end of the code
becomes
| |||||
| matanuragi (22) | |||
| dear sir, kindly try this #include <iostream> #include<conio> using namespace std; int main () { cout << "Hello World!"; getch(): return 0; } with regards, matanuragi | |||
| Duoas (1596) | |||
| @matanuragi No one here is so stupid that you have to repeat yourself. <conio.h> is a non-portable library in any case. @alexcook There is a thread at the top of this forum entitled Console Closing Down. It deals specifically with your problem. Good luck. | |||
This topic is archived - New replies not allowed.
