+ 1

When I am making a simple programme called Hello World!

My programme is open and close immediately! I am writing same as shown in this application. why this is happening?

26th Dec 2016, 11:12 AM
Granth Pandya
Granth Pandya - avatar
6 ответов
+ 4
i think you r using turbo c++, if so, then include <conio.h> headerfile, and use function getch(); whenever (or wherever) you want to hold your output screen.
26th Dec 2016, 11:54 AM
Nikhil Dhama
Nikhil Dhama - avatar
+ 2
add getch(); before return 0;
26th Dec 2016, 11:16 AM
Uran Kajtazaj
Uran Kajtazaj - avatar
+ 2
Thanks Nikhil
26th Dec 2016, 12:14 PM
Granth Pandya
Granth Pandya - avatar
+ 2
You can also use cin.get(); an alternative I recently learned as an alternative of getch(); also getch() doesn't work if you're coding in VisualBasic so use _getch(); instead. Happy Coding.
10th Jan 2017, 3:15 PM
Navneet Sharma
Navneet Sharma - avatar
+ 1
It does that because the program runs so fasts that the console window shows up, writes the stuff and closes immediately. This is intended and could be countered with functions that wait for input (cin, getch) or an endless cycle. Or you could run your program from console window (linux style) and that would stay until you manually close it.
26th Dec 2016, 1:09 PM
Norbivar
Norbivar - avatar
+ 1
are u am good developer???
5th Jan 2017, 9:08 AM
jonayed.neer