+ 2

Does anybody use Visual Studio?

I am buildig the basic "Hello world!" program, and I have no errors on my build, but I cannot see the output. A window flashes on and off when i run it, which I assume is where "Hello World" is printed, but how do I make it stay on screen so I can see it? i think thia must be a settings issue. Thank you

19th Jul 2017, 7:02 PM
Richard Appleton
Richard Appleton - avatar
6 Answers
+ 9
The recommended way to halt output window from exiting is to add getchar() before return 0.
20th Jul 2017, 3:38 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
At the end of your program, you can add these two lines (in your main() function): cout << "Press any key to continue..." << endl; cin.get()
19th Jul 2017, 7:21 PM
Keto Z
Keto Z - avatar
+ 2
Or before "return 0;" write: std::system("pause>nul");
19th Jul 2017, 7:35 PM
Jakub Stasiak
Jakub Stasiak - avatar
+ 2
@Jakub I will have to try that soon
19th Jul 2017, 9:20 PM
Manual
Manual - avatar
+ 1
or you can assign a variable(like I) at the top of the main function and then go to main function and on last line write cout << I;
19th Jul 2017, 8:32 PM
Shervin Jarrahi
Shervin Jarrahi - avatar
0
I use, but I have problems when I need to erase a line.
9th Dec 2020, 1:55 PM
Erica U
Erica U - avatar