where am i wrong

What is the problem with this code.
Its not printing the 2nd printf!!!!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "stdio.h"
int array[] = {23,34,12,17,204,99,16};
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))

 int main()
 {
     int d=0;
	 printf("\n elements -> %d\n ",TOTAL_ELEMENTS);
 
	 for(d=-1;d < TOTAL_ELEMENTS;d++)
	 {
		 printf("ISTS");
		 printf("\n  hii %d \n",array[d+1]);
	 }

     return 0;
 }


Thanks in advance...
Andy
why is d = -1 in the for?
(sizeof(array) / sizeof(array[0]))
would return an unsigned value, being d signed and negative can produce weird behaviour
Thanks for clarification :)
"We should not mix signed and unsigned without proper cast."


Topic archived. No new replies allowed.