CMD BOX STILL WONT OPEN!

Ok so yesterday i had posted that when i go to run evena simple program in visual studio 2008 using the f5 button the cmd box like flashes on the screen then disappears! I tried to put that piece of code somebody left on the question yesterday into thwe end of int Main() and it did nothing!
show the code
closed account (NyqLy60M)
Seems to me it's a compiler flaw, but I'm sure there's a decent explanation behind it.

What I recommend doing is including the <limits> library and adding this bit of code to the end of main():

1
2
std::cout << "Press ENTER to continue..." << std::endl;
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');


The command prompt will remain open until the user either closes it manually or hits the enter key. (Never use system commands)
closed account (iAk3T05o)
Use ctrl + f5. The f5 won't work for console programs. I had that same problem.
closed account (z05DSL3A)
Vemc wrote:
Seems to me it's a compiler flaw, but I'm sure there's a decent explanation behind it.
It is not a compiler flaw, it is doing exactly what it should be doing. If you run the program from outside the IDE by double clicking its icon it will do the same thing.

closed account (NyqLy60M)
@Grey Wolf:

I think you misunderstood me. If you take MinGW for example, console-based applications automatically wait for the user's response before closing.

Running the program from outside the IDE is absolutely no different.
add std::cin.get() and press F5, it should work...
The difference between F5 and Ctrl+F5 is that the first executes your program in "debug mode" while the second executes it in "release mode".

Downey still has not shown us his code. If something is causing it to fail immediately then no amount of "pause"ing will help.

Suggestion: just open a terminal prompt, "cd" to the executable's directory, and run it from there.


C:\Users\Downey> cd "Documents\Visual Studio 2012\Projects\ConsoleApplication1\Release"

C:\Users\Downey\Documents\Visual Studio 2012\Projects\ConsoleApplication1\Release> ConsoleApplication1.exe

...
The difference between F5 and Ctrl+F5 is that the first executes your program in "debug mode" while the second executes it in "release mode".


<technicality>
They both run your program in whatever build configuration you have selected. The difference is that F5 attaches the VS debugger whereas Ctrl+F5 doesn't.
</technicality>
(Sorry, I should have been more specific about that.)
Topic archived. No new replies allowed.