Sunday, 15 April 2012

Printing variable values to console visual c++ windows store Modern UI app -


I'm just starting to learn C ++ / XAML Windows Store app development, but I can not find good for my life How to Print Variable Value in "Output" window in VS 2012

debug.proved () is not present for the Windows Store app and I have a way to print out a OutputDebugString () I can not use variable values ​​to print (without some heavy formatting).

An easy way to print an example line is:

Position of the mouse X: 12

For example, Where 12 is an integer that comes from MouseDelta . >

Thank you for your time,

Poncho

Here's a good alternative:, basically it allocates to the console for your Windows Store app, obviously this certification will fail but given that it may only be for debug purposes, it will be fine . I am copying the relevant code here:

  // Include Windows.h for WINBASEAPI and WINAPI: #include & lt; Windows.h & gt; // Announce your AllocConsole, because Windows.h leaves it: extern "C" WINBASEAPI int WINAPI AllocConsole (); Auto Main (Platform :: Array & LT; Platform :: String ^ & gt; ^) - & gt; Int {AllocConsole (); Std :: wcout & lt; & Lt; L "Hello there!" & Lt; & Lt; Std :: endl; Std :: getchar (); Return EXIT_SUCCESS; }   

However, if you want to see such output inside your app, then you want to use it, which applies the part of the .NET System.Console and secure it. As can be used within the Windows Store apps.

No comments:

Post a Comment