I'm attempting to learn C at my school, and I'm going through Stephen Kochan's Programming in C book. I just recently tried to compile 7.1, but I got some definately odd results.
Here's the code itself:
Code:
#include <stdio.h>
int main (void)
{
int values[10];
int index;
values[0] = 197;
values[2] = -100;
values[5] = 350;
values[3] = values[0] + values[5];
values[9] = values [5] / 10 ;
--values[2];
for ( index = 0; index < 10; ++index )
printf ("values[%i] = %i\n", index, values[index]);
return 0;
}
And my output:
Code:
values[0] = 197
values[1] = 4198445
values[2] = -101
values[3] = 547
values[4] = 37814120
values[5] = 350
values[6] = 37814124
values[7] = 895
values[8] = 37814176
values[9] = 35
Shouldn't the uninitialized values (1, 4 and 6-8) be zero? Could somebody explain this to me please?