In this program the TOTAL_ELEMENTS calculates properly when not used in for loop. And the first printf prints properly.
But why the 2nd printf is not working even if the condition in the loop is true. TOTAL_ELEMENTS returns 7.
And -1<7-2 i.e -1<5 is true. So what is wrong here?
#include<stdio.h>
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = {23,34,12,17,204,99,16};
int main()
{
int d;
printf("Total= %d\n", TOTAL_ELEMENTS);
for(d=-1;d <= (TOTAL_ELEMENTS-2);d++)
printf("%d\n",array[d+1]);
return 0;
}