整数があります : (using xcode
for iPhone ) 。
int wordCounter=1;
後で、forループでポインタとして配列を埋めると、特定の数値になった後、どういうわけか0になります。プログラムのバグを何度もチェックしましたが、どこにも減分がないことに気付きました。私は持っています wordCounter++
。
今、私はこのような多くの行があることを見てきました.それらの後にそれは 0 になります:
if(tempBinary[countWords-1][j] != tempBinary[countWords][j])
だから私はcountWords-1
それを何度も減らすことを考えていました、それは可能ですか?プログラム全体で、この変数に対して他のデクリメントまたは初期化を行う必要はありません。tempBinary
サイズ7として定義されている場合、5で初期化され、5の場合は3でゼロになることがわかりtempBinary
ます..配列がオーバーフローしてゼロになっている可能性はありますか? 私はそうは思わない..
ここで何が問題なのですか?ありがとう 。
EDIT (問題のある状態の 1 つ)
int countWords=1;
int stabilityK=0;
tempBinary[0][0]= tempBinary[0][1]=tempBinary[0][2]=tempBinary[0][3]=tempBinary[0][4]=tempBinary[0][5]=tempBinary[0][6]=tempBinary[0][7]=1 ;
for(int k=0;k<numOfBuffers;k++)
{
NSLog(@"countwords:%d",countWords-1);
float *temp=getFFT(buffersRing[k],buffersRing[k][0]);
for(int j=0;j<wordSize;j++)
{
switch(state_on_signal)
{
case WAIT_FOR_SECOND_CHANGE:
//get new word
if(temp[goodBins[j]] > decisionLine[j])
tempBinary[countWords][j]=1;
else
tempBinary[countWords][j]=0;
if(tempBinary[countWords-1][j] != tempBinary[countWords][j])
newData=1;
NSLog(@"s1: countwords:%d",countWords-1);
if(j==wordSize-1)
{
NSLog(@"s2: countwords:%d",countWords-1);
NSLog(@"PRE TEMP:%d%d%d%d%d%d%d%d",tempBinary[countWords-1][0],tempBinary[countWords-1][1],tempBinary[countWords-1][2],tempBinary[countWords-1][3],tempBinary[countWords-1][4],tempBinary[countWords-1][5],tempBinary[countWords-1][6],tempBinary[countWords-1][7] );
NSLog(@"NEW TEMP-WAIT FOR SECOND CHANGE :%d%d%d%d%d%d%d%d",tempBinary[countWords][0],tempBinary[countWords][1],tempBinary[countWords][2],tempBinary[countWords][3],tempBinary[countWords][4],tempBinary[countWords][5],tempBinary[countWords][6],tempBinary[countWords][7] );
NSLog(@"s3: countwords:%d",countWords-1);
//TAKE NEW DATA
if(newData==1)
{
NSLog(@" TOOK new BINARY at current k:%d, so took data at: %d",k,(k+markedK)/2);
for(int s=0;s<wordSize;s++)
{
if( getFFT(buffersRing[(k+markedK)/2],buffersRing[(k+markedK)/2][0])[goodBins[s] ] >decisionLine[s] )
binary[countWords-1][s]= 1;
else
binary[countWords-1][s]= 0;
}
NSLog(@"s4: countwords:%d",countWords-1);
NSLog(@"BINARY%d: %d%d%d%d%d%d%d%d :%d",(countWords-1), binary[(countWords-1)][0], binary[(countWords-1)][1], binary[(countWords-1)][2], binary[(countWords-1)][3], binary[(countWords-1)][4], binary[(countWords-1)][5], binary[(countWords-1)][6], binary[(countWords-1)][7],[self getDecimal:binary[countWords-1]]);
countWords++;
markedK=k;
state_on_signal=WAIT_FOR_STABILITY;
}
newData=0;
}
break;