如何在调试过程中查看 Visual Studio 2008 中结构元素的值?
例如,
structure S{
int a;
int *b;
}s;
//现在当我尝试检查存储的值时...
s->a = ?
s->b[0] = ?
s->b[1] = ?
..等等
我如何“添加监视”或使用任何其他技术来检查值?请告诉我。谢谢。
For example,
structure S{
int a;
int *b;
}s;
//now when I try to check the values stored...
s->a = ?
s->b[0] = ?
s->b[1] = ?
.. and so on
How do I "add watch" or use any other technique to check the values? Please let me know. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您想要在调试器中检查一个
S*
类型的值。最简单的方法是在监视窗口中键入生成值的表达式。例如,如果您有一个名为pValue
的本地文件,只需棘手的部分是查看
S 中的所有值::b
因为它将显示为单个指针而不是数组。为了将值视为数组,您只需告诉调试器有多少个元素。例如,如果有 5 个元素,您可以在监视窗口展开中输入以下内容,它将显示
pValue->b
中的前 5 个int
值It sounds like you have a value of type
S*
that you want to inspect in the debugger. The easiest way to do this is simply type the expression which produces the value into the watch window. So for example if you have a local namedpValue
simplyThe tricky part is seeing all of the values in
S::b
as it will be displayed as a single pointer vs. an array. In order to see the value as an array you just need to tell the debugger how many elements there are. For example if there were 5 elements you could type the following into the watch windowExpanding that will show you the first 5
int
values inpValue->b