Printing with for loops
lets say i have an array with 240 bits and i want to print the values in ordinals that are not consecutive. like:
1 2 3 4
|
for(i=80; i<86; i++) printf("%d", encoded_lcw[i]);
for(i=90; i<96; i++) printf("%d", encoded_lcw[i]);
for(i=100; i<106; i++) printf("%d", encoded_lcw[i]);
for(i=110; i<116; i++) printf("%d", encoded_lcw[i]);
| |
Is there any way to do get the same result with a one liner? Thanks!
1 2 3 4 5 6
|
for (int i = 80; i < 116; i++)
{
printf("%d", encoded_lcw[i]);
if (i % 10 == 5)
i += 4;
}
| |
nice! Thanks a bunch!!
Topic archived. No new replies allowed.