Quickie - VS 2003 C++ compiler option to keep console open?

Started by
14 comments, last by gan 18 years, 10 months ago
Quote:Original post by Nemesis2k2
Actually, that requires the windows.h header to be included.

I was going to tell you you're wrong, but it turns out I'm mistaken. VS2003, with an empty Win32 Console Project does not require windows.h specifically. Apparently <iostream> does the trick. I had assumed if it was defined anywhere, it wouldn't be in <iostream>, and a program with that as the only include still functioned. Oops.

I like this much, much more than cin.get(). That requires your keypress be Enter. Maybe its not portable, but its a hack for debugging purposes. The code will probably be taken out at the end whatever solution you go with.

CM
Advertisement
Quote:Original post by Lajnold
Quote:Original post by MaulingMonkey
My emphisises (?). This means #include <cstdlib> for C++, and find system in the std:: namespace.


I don't think any of the functions from C is wrapped in namespaces, so the std:: part isn't needed.


It is if you #include <cstdlib> instead of <stdlib.h>, like the part you quote suggests.
Quote:Original post by Urxae
It is if you #include <cstdlib> instead of <stdlib.h>, like the part you quote suggests.


Then that may be different in different compilators. I, using VC++ 7.1, don't need to specify that it is in the std namespace. But now when I have tried, I see that it is possible to compilate both system() and std::system().
I noticed that I wasn't logged in, but it was me who wrote previous note.
Quote:Original post by Anonymous Poster
Then that may be different in different compilators. I, using VC++ 7.1, don't need to specify that it is in the std namespace. But now when I have tried, I see that it is possible to compilate both system() and std::system().

That's an error on Microsoft's part. Officially, #include <cblah> in C++ is suppsoed to be identical to #include <blah.h> in C, except that functions are all hidden away in the std namespace. <blah.h> doesn't have to be provided at all.

CM
Quote:Original post by paulecoyote
Is there a VS 2003 C++ compiler option that keeps a console application open after it has finished running?

Yeah I know I could just use cin or something at the end, but I just want that console window to stay open until I close it so I can see what it's output. I'm sure I've used the feature before, but probably in a different compiler & IDE.

Cheers,

Paul


Do u mean _getch() and <conio>?

This topic is closed to new replies.

Advertisement