I'm fairly new to visual studios/window aplications, so im not used to not having a command line.
Basically I have for example a CString m_storeEx = "12 + 2 - 4 "
and so I used tokenize method to put each number and operator into an array by doing this:
CStringArray arr;
CString resToken= m_StoreEx.Tokenize(_T(" "),curPos);
while (resToken != _T(""))
{
arr.Add(resToken);
resToken = m_StoreEx.Tokenize(_T(" "), curPos);
}
I want the end result to be an array like this arr = ['12', '+', '2', '-', '4']
I just want to check if im adding the elements in right. Usually if I code with something that has a commandline, I'd just make a for loop, and print the array out to check. But I'd know to do that in MFC visual basics since there is no command line. I tried using the debugging tool to check the value of the array, but it just gave me weird numbers and letters.
As pointed out by l33t in his/her answer, Visual Studio has provisions to extend and customize the visualization of objects in the debugger. Details are available under Create custom views of native objects. By default, Visual Studio doesn't ship a CStringArray
visualizer, so you are left with writing your own.
The following is a simple visualizer, that displays both the collection size as well as its contents:
<?xml version="1.0" encoding="utf-8"?>
<AutoVisualizer xmlns="http://schemas.microsoft.com/vstudio/debugger/natvis/2010">
<Type Name="CStringArray">
<DisplayString>{{size={m_nSize}}}</DisplayString>
<Expand>
<ArrayItems>
<Size>m_nSize</Size>
<ValuePointer>m_pData</ValuePointer>
</ArrayItems>
</Expand>
</Type>
</AutoVisualizer>
There are several ways to enable this visualizer. The easiest deployment is to copy the XML code above to a file (e.g. CStringArray.natvis) and copy that file to the directory %USERPROFILE%\My Documents\Visual Studio 2012\Visualizers\
. Other alternatives are documented in the link above.
Once deployed, stepping through the following code
CStringArray str;
str.Add( _T( "12" ) );
str.Add( _T( "+" ) );
str.Add( _T( "2" ) );
str.Add( _T( "-" ) );
str.Add( _T( "4" ) );