I have two arrays and out of both I have to get the Values of specific Indices. While doing this I have comme accross something odd. When I print out the value at index -1 of arr1, I get 0 and the same thing happens with index 8. I concluded that inidces outside the range of an array are returned as 0. Now my problem. When I do the same thing with arr2, I get 29 as the Value of index -1.
What am I doing wrong?
int arr1[] = {33, 12, 75, 85, 62, 14, 100, 29};
printf("Nummer -1: %d\n",arr1[-1]); //outputs 0
printf("Nummer 8: %d\n",arr1[8]; //outputs 0
int arr2[] = {85, 15, 84, 96, 4, 45, 55, 12, 25, 68};
printf("Nummer -1: %d\n",arr2[-1]); //outputs 29
Note: I use Code:Blocks on Linux Mint with the gcc compiler