Note that there are some explanatory texts on larger screens.

plurals
  1. POinteger that becomes 0 in a strange way
    primarykey
    data
    text
    <p>I have an integer : (using <code>xcode</code> for iPhone ) .</p> <pre><code>int wordCounter=1; </code></pre> <p>Later on, when i fill arrays with it-as a pointer,in a for loop, it somehow becomes 0 after it becomes a certain number . i have checked my program many times for bugs, and i realize that i dont even have a decrement on it anywhere . i do have <code>wordCounter++</code>.</p> <p>Now i have seen that i have many lines like this,that after them it becomes 0 :</p> <pre><code>if(tempBinary[countWords-1][j] != tempBinary[countWords][j]) </code></pre> <p>so i was thinking that <code>countWords-1</code> decrement it down again and again, is that possible? i dont have any other decrement or initialization on this variable in my whole program. i COULD see that when the <code>tempBinary</code> defined as size 7, it initialize at 5, and if <code>tempBinary</code> is 5, it zeroing on 3 .. is it possible that the array is overflow and is zeroing it? i dont think so..</p> <p>whats wrong here ? thanks .</p> <p><strong>EDIT</strong> (one of the problematic states)</p> <pre><code>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&lt;numOfBuffers;k++) { NSLog(@"countwords:%d",countWords-1); float *temp=getFFT(buffersRing[k],buffersRing[k][0]); for(int j=0;j&lt;wordSize;j++) { switch(state_on_signal) { case WAIT_FOR_SECOND_CHANGE: //get new word if(temp[goodBins[j]] &gt; 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&lt;wordSize;s++) { if( getFFT(buffersRing[(k+markedK)/2],buffersRing[(k+markedK)/2][0])[goodBins[s] ] &gt;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; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload