I researched this and tried the solutions; CNTRL+F5, add system("pause");, placed a break at line2 and added cout << "Test" << endl << endl; to line 1 of main(), checked the properties/linker/system/subsystem/console. No solution.
Why else would my program be opening and then closing every time I run debug? It has run before in VS2005 and compiles without errors in VS2008 in x64 Win7.
I tried most of the suggestions in that thread but none of them worked. When I run a test code the consul stays open. But if I comment everything out of my code and add the same test code, the consul closes.
So, you comment everything out and it closes? What do you expect?
Anyway, what IDE are you using? If you're using VS20xx, should be able to just "run without debugging" or something along those lines. Code::Blocks stays open by default. Not sure about Bloodshed, never used it.
funny dude - I commented everything and then added a test code that worked in a test project. And, yes VS2008, per my first post. What are Code::Blocks and Bloodshed?
'start without debugging' results in the consul and 'press any key to continue' I press a key and the consul closes.
If your debugger does not break at the break point, then there is something wrong with it or with the IDE that put the break point. Check that you are using it properly and issue a bug to your vendor.
No, only in the most broad sense does it solve my problem. My intuition is that the IDE is functioning fine and there is something deeper that is the issue. What are some of the other reasons the described behavior is happening?
There is no deeper reason. You write a console program. You ask the IDE to run it. The IDE has to open a console to run it. When the program ends, the console closes.
If you want the console to stay open, run it from the console. This will involve you opening a console and typing.
int main()
{
int t;
while (t < 1000) {
cout << "Welcome to the Automating Activity Coding from Model and Sensor Data" << endl << endl;
t++;
}
return 0; //goodbye!
}
This should run fine and the console should display the scrolling text long enough that I should see it, but there is nothing. This question is posted to a lot of forums, and often the answer is simple but there a lot where the question is not answered.
I have read most of those threads and so-far they are not applying to me. Most suggest using a consol project type, so I just tried an empty project type.
I am starting to suspect that my C++ class used a special console setup that they decided we were too dumb to understand and would just figure out later.
You're over thinking this. Moschops explained exactly what is happening. Your program executes, and then the closes the console window because it is done with it.
If you want it to stay open, either run from the console, or use one of the various suggestions to keep it open.
Yes, I hear what you are saying and understand that the console logically should close when the program is completed. But, this specific program has always kept the console open with a menu and request loop for inputing a menu choice. I had to change the class library and resolve some compiler errors to run in VS2008 - and now the console closes.
good catch, I changed to int t = 0;
but the console still opens and then closes - even with 10,000 loops of "welcome..."