Assume you have a complex structure (e.g. hash table) that you hold ptr to (pHash).
Now in the middle of nowhere, you would like to print the data within pHash (with no real time edit+compile) .
Is it possible in Visual Studio? and if so how?
Assume you have a complex structure (e.g. hash table) that you hold ptr to (pHash).
Now in the middle of nowhere, you would like to print the data within pHash (with no real time edit+compile) .
Is it possible in Visual Studio? and if so how?
If pHash is an array you can set a watch on pHash. Click on the watch line and add ",<num_elements>" and the debugger will show you the elements of the array.
Example:
pHash,10 - shows the first 10 elements of the pHash array.
You can also look into stringstream, vectors, etc this way. MSVC 2005+ is able to examine the contents of most STL containers but there are a few that the debugger still does not support.
For stringstream:
std::ostringstream ostrm;
ostrm << "Hello";
Debugger:
ostrm._Stringbuffer._Seekhigh,<num_characters>
This works with any data object you put a watch on. You can directly access any of the internal elements of an object by using the dot operator. For more advanced debugging I recommend purchasing a book about debugging in MSVS. There are a lot of things it can do but does not do out of the box.
Last edited by VirtualAce; 12-28-2011 at 11:07 AM.
Switch to the Immediate window and type in a function call, for example PrintMyHash(pHash) or whatever
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
we already managed but thanks, apparently this is not trivial, not all functions you can run