Some example code to start the question:
#define FOO_COUNT 5
static const char *foo[] = {
"123",
"456",
"789",
"987",
"654"
};
The way this would normally be iterated over, as for one example, is the following:
int i = FOO_COUNT;
while (--i >= 0) {
printf("%s\n", foo[i]);
Is there anyway to do the above without explicitly having the human count the number 5? In the future I might add/remove elements and forget to update the size of the array, thus breaking my app.
1 Answer