|
-
December 1st, 2008, 11:10 AM
#1
[RESOLVED] Console Output Behaviour Question
Not only am I new to these forums, I'm also new to Visual C++... I've got about 2 weeks under my belt now. I'm teaching myself through books and forums.
I've just started working through the book C++ a Beginner's Guide, by Herbert Schildt, which is freely available and hosted by microsoft here.
Right now I'm using the Visual Studio 2005 Command Prompt to create .cpp files, and then compile them. This is working fine. The issue is that when i run a compiled simple program the console window flashes up and then immediately disappears. I was expecting it to remain open so I could actually see the cout I wrote into the code.
Here's a code example:
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!";
return 0;
}
When I run the compiled version of the above code the console window flashes and immediately disappears. Is this normal behaviour? If not, what do I need to do to force the console to remain open so I can see it?
NinjaEdit: I recently discovered this happens because of the 'return 0;' statement; that's why the console closes immediately. I also discovered that by calling the .exe from an already open console window I can see the output resulting from the program, and the console window will remain open.
Last edited by CreganTur; December 1st, 2008 at 12:19 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|