mplab - Copying every nth element from one array to another -


does know of way copy every nth element 1 array another? example, have array data[x] , want copy every third (3rd) element - data[0], data[3], data[6] etc new array data2[j]. tried using loop no success.

void storedata() { bufferpointer1 = &buffera[0]; x=0; i=0; j=0;  while (x<no_samples-1) {     data[x] = *bufferpointer1;     bufferpointer1++;     x++;     (j=0; j<127; i++)         {         data2[j] = data[i+=3];         j++;         } } } 

why aren't declaring variables in function? 4 of them seem used locally , should not visible outside function.

why increment in section instead of j, typo?

   (j=0; j<127; i++)         {         data2[j] = data[i+=3];         j++;         } 

i write this:

   (j=0; j<127; j++)         {         data2[j] = data[i];         i+=3;         }     i=0;                      // reset pointer 

Comments

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -