Basic pointer question

So I have the following code:
*(pol1Card1+(i-1)) = ( *(pBuffer+(8*i-8)) + *(pBuffer+(8*i-6)) + *(pBuffer+(8*i-4)) + *(pBuffer+(8*i-2))/4 ) ;

I am trying to group data points into the array called pol1card1.

Is my code actually taking the values from pBuffer or the memory address? Because I want to take the values.

when that line is over, does the value in *(pollCard+(i-1)) make sense?
Yes you are taking the values in the actually buffer.

Although I don't know why you like the harder to read and type *(x+(y)) syntax. The more traditional x[y] syntax is much more clear.

Compare:

 
pollCard1[i-1] = ( pBuffer[8*i-8] + pBuffer[8*i-6] + pBuffer[8*i-4] + pBuffer[8*i-2] / 4 );


Also, you probably wanted to put that / 4 outside the parenthesis, not in them...
Topic archived. No new replies allowed.