Hi,
I have an array with 8 elements and I want to print the lower 4 elements with for 8 loops and the index starts from 3, so it prints element[3], element[2] element[1], element[0], and the rest to zeros but I want when the index reaches 0 and starts to print from index 3 again, how to do that? I tried this code but didn't work, it prints until the last element but the rest are zeros. I want a to be initialized with 3 again. If I tried a==0, it prints 3 elements and skips element[0].
Code:
uint8_t ascend[8]={0x09, 0xc0, 0x20, 0x1f, 0x1f, 0x20, 0xc0, 0x00};
uint8_t i,a=3,cnt=8;
int main(void) {
for (i=0;i<cnt;i++)
{
printf("data 0x%.2x\n",ascend[a--]);
if (a<0)a=3;
}
return 0;
}