問題描述
如果您有一個靜態(tài)分配的數(shù)組,Visual Studio 調(diào)試器可以輕松顯示所有數(shù)組元素.但是,如果您有一個動態(tài)分配并由指針指向的數(shù)組,則當(dāng)您單擊 + 將其展開時,它只會顯示該數(shù)組的第一個元素.有沒有一種簡單的方法可以告訴調(diào)試器,將此數(shù)據(jù)顯示為類型為 Foo 且大小為 X 的數(shù)組?
If you have a statically allocated array, the Visual Studio debugger can easily display all of the array elements. However, if you have an array allocated dynamically and pointed to by a pointer, it will only display the first element of the array when you click the + to expand it. Is there an easy way to tell the debugger, show me this data as an array of type Foo and size X?
推薦答案
是的,很簡單.說你有
char *a = new char[10];
在調(diào)試器中寫入:
a,10
會像數(shù)組一樣顯示內(nèi)容.
would show you the content as if it were an array.
這篇關(guān)于如何在 Visual Studio 調(diào)試器中顯示動態(tài)分配的數(shù)組?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!