# Simple Debug Output

This topic is 4899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi I am just after starting into the deep and wonderful world of DirectX programming in C++. Up until now the only language I really used was java and a bit of c++ console programming. In java even when you are programming using a GUI the console window is still visible. This is an indispensable tool for debugging where any output can be sent. I am looking to see if this is possible in C++ windows programming. A place where I can send int's, float's and string's for easy viewing during runtime. Does anyone know of a method of doing this./ thanks John.

##### Share on other sites
Try the OutputDebugString(), it takes a LPCTSTR but(if you don't know) you can make floats, int etc. to char* like this:
#include <stdio.h>//Other codefloat Angle=1.54f;char Buffer[1024];sprintf(Buffer,"Angle is %f",Angle);//Other code

and then call "OutputDebugString(Buffer);" you need to include "Windows.h" to use OutputDebugString, i suppose you use Windows since you say you are working with DX.

##### Share on other sites
Rasmus gave you an excellent answer. I just wanted to point out that OutputDebugString sends its output to the debugger, which ends up displayed in the debug window within the IDE. This is the proper and better way to do it.

If you want to create a console for your Windows application for other purposes, however, use the AllocConsole API (and FreeConsole to clean it up). Again, this is not for debugging purposes.

##### Share on other sites
Thanks for the posts guys both methods work great.