C
crazy
Hi
It seems something really simple, but can't figure out.
It's not my homework
, was just looking at some C problems on the web
and came across this one.
why doesn't the following code print anything?
#include <stdio.h>
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = {1,2,3,4,5,6,7};
int main()
{
int d;
for(d=-1;d <= (TOTAL_ELEMENTS - 2);d++)
printf("%d\n",array[d+1]);
return 0;
}
crazy
It seems something really simple, but can't figure out.
It's not my homework
and came across this one.
why doesn't the following code print anything?
#include <stdio.h>
#define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0]))
int array[] = {1,2,3,4,5,6,7};
int main()
{
int d;
for(d=-1;d <= (TOTAL_ELEMENTS - 2);d++)
printf("%d\n",array[d+1]);
return 0;
}
crazy