How to add a Console and Output to an existing New Empty Project

Started by
8 comments, last by SmkViper 9 years, 7 months ago

Hi Everyone,

I started a new Empty Project a couple of months ago and now I'm realizing that I could really use a console and output to it for debugging purposes.

How do I add that feature to my existing program?

Could anyone help me with that?

Thanks a lot.

Cydriic

Advertisement

Simple console approach for Windows:

using Visual Studio, create a console app project - the entry point with be _tmain(...). The app will open in a console window. "#include <iostream>" will provide std::cout and std::cin. You can use std::cout << "Some debug info: " << some_debug_value << "\n"; as desired.

From _tmain, call your app starting point.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Hi BuckEye and Thank you for your Reply...

I'm trying to add a Console to an existing project, not start a new Console Window Project.

How do I add the Console to a Project that was started as an Empty Project at the Origin?

assuming visual studio, open the project property pages. linker-->system-->subsystem. Choose console and add a main() entry point for the program.

int main( void ){

//good enough

}

how did you create the empty project though? Looks like you have to pick windows,console, dll, or static lib when you create a new project.

The Four Horsemen of Happiness have left.


I'm trying to add a Console to an existing project, not start a new Console Window Project.

You're providing no information on what IDE you're using, what operating system, etc. Both jms bc and I are just making guesses. It sounds like you might be using Visual Studio and Win32. If you want more specific answers, provide some specific information - what IDE? what version? what API?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Looks like you're probably looking for the

AllocConsole function to add a console to a window'd project.

I Everyone and Thank you for your answers.

I am using Microsoft Visual C++ 2010 Express on Windows 7 and Programming on OpenGL API.

I'm trying to get a Console to Open in the BackGround of my application so that I can Output Values to debug my 3D Game when I'm encountering issues and I need where some values are at and how they are behaving.

Thanks a lot guys.

Cydriic

-

Here you go:

http://justcheckingonall.wordpress.com/2008/08/29/console-window-win32-app/

You might also like:

http://msdn.microsoft.com/en-us/library/windows/desktop/ms682073(v=vs.85).aspx

http://stackoverflow.com/questions/5068392/create-window-console-inside-main-win32-window

http://www.cplusplus.com/forum/windows/58206/

If all you want is to spit out text so you can see what's going on in your program then you don't need a whole console for that, just use OutputDebugString and whatever you give it will go to MSVC's output window in the IDE.

This topic is closed to new replies.

Advertisement