从XCode调试控制台打印C数组索引内容

时间:2012-11-22 00:02:25

标签: c++ objective-c c audio buffer

我正在寻找一种方法将C样式数组索引的内容打印到XCode 4.5中的控制台窗口。换句话说,当我的音频缓冲区(一个C数组)被浮点数据填充时,我在填充后放置一个断点,我想只打印我的数组[]中的内容值。我尝试过以下方法:

// Just an example of what I'm doing. The following is a buffer that I am declaring:
int total = 235377;
float tmpArr[total];

// gives me the first index [0] contents value only when I type this in the console window in Xcode
p tmpArr

// gives the following error:
// error: subscripted value is not an array, pointer, or vector
// error: 1 errors parsing expression
p tmpArr[3]

// gives me the address as expected
p &tmpArr

// the following seems to access contents but is casting them to ints and therefore truncating anything after the decimal...in audio programming, the float data is between 0 and 1 sooo....
frame variable -ffloat tmpArr
frame variable -ffloat tmpArr[3]

我试图找到答案,为什么我无法访问数组索引的内容。我在这里错过了什么吗?每次我想调试时,是否必须将printf()置于for循环中?谢谢!

更新

正如@Daniel Fischer所指出的,在XCode控制台中键入p *(tmpArr + indexNumber)成功访问tmpArr [indexNumber]并将其打印到调试控制台。

0 个答案:

没有答案