[.net] A little problem with a very simple C++ code

Started by
2 comments, last by DvDmanDT 17 years, 2 months ago
Well, Below I have a very simple console app code in C++ written using Microsoft Visual C++ 2005 .NET. When I run this simple program it runs fast and then disappears. I'd like to know what command I have to write in order to make its window on my screen. #include <iostream> #include <stdio.h> using namespace std ; void main() { cout << "How are you??!?!" << endl; }
Advertisement
If you put

std::cout << "Press the enter key to exit";std::cin.ignore(std::cin.rdbuf()->in_avail() + 1);


at the end of the main function it will stay there. ('til you press enter).

(Trick from Beginning C++ game programming)
You shouldn't put a pause command in the program itself. You should run it from the editor with Ctrl+F5, or run it from a command prompt.
You could also set a breakpoint (F9) on the last line..

This topic is closed to new replies.

Advertisement