I have seen some C programs use the sizeof operator to bound loops while iterating over an array. What is the correct method for doing this? I have the example as follows:
#include <stdio.h>
int main(void)
{
size_t i;
char a[100];
/* Edited '<=' to '<' as suggested */
for ( i = 0;i < sizeof a / sizeof *a; ++i)
a[i] = i;
for ( i = 0;i < sizeof a / sizeof *a; ++i)
printf("%d\n", a[i]);
return 0;
}