How is it that this comes back with a value for array[6]?
#include <iostream>
using namespace std;
int main()
{
int z;
char array[5];
array[0] = 28;
array[1] = 14;
array[2] = 68;
array[3] = 100;
array[4] = 225;
array[6] = 30;
cout << array << endl;
cout << array[6];
return 0;
}
My understanding of arrays is that they are more like pointers to memory where the memory is set by the initialization in this case 5. However, when I place a value for the 6th element it will compile even though it was not a set element. It does not show as part of the array, but I can print the element by itself. Is this because it is just as I thought merely a pointer? It seems that 6 is not part of the container though because it only prints individually and not part of the array. Am I right in thinking this way or is this just one of those friendly compiler issues that I need to be aware of?