Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to log stuff in console in Visual Studio C++

I'm working on a little C++-Game in Visual Studio 2008. I want to see the content of a vector after a couple of seconds or after I pressed some buttons. Breakpoints are useless in this case, because they stop me at every call of the gameloop (~60 times per second). How do I debug in this case?

Thanks!

like image 426
Korbi Avatar asked May 03 '09 19:05

Korbi


Video Answer


2 Answers

Use function OutputDebugString from Windows API. You can call it anytime you want e.g. every 100th loop in your code.

Function info is here

Please read all comments on this page - some people claim that in your IDE (VS2008) output of this function is shown in "Immediate Window" not the "Output".

like image 59
Wacek Avatar answered Oct 27 '22 07:10

Wacek


You can set conditional breakpoints, i.e. breakpoints which hit at a certain position only when a given expression is true. You can, for example, set a breakpoint which hits only every nth time in a loop.

like image 43
JesperE Avatar answered Oct 27 '22 07:10

JesperE