M
Michael W. Hicks
Hello,
Consider the following code snippet:
int x[ 3 ] = { 1, 2 };
What is the value of x[ 2 ]?
My assumption was that this value is undefined and dependent upon the
compiler implementation, as well as the compilers settings. However, I
recently took a C++ programmer's test and the test stated that the value of
x[ 2 ] is 0. Doing a quick test with a sample debug program on Visual C++
6.0 affirms that the value of x[ 2 ] is 0. Is this a C++ standard directive
and am I wrong? Or was the test hogwash?
Thanks,
Mike
Consider the following code snippet:
int x[ 3 ] = { 1, 2 };
What is the value of x[ 2 ]?
My assumption was that this value is undefined and dependent upon the
compiler implementation, as well as the compilers settings. However, I
recently took a C++ programmer's test and the test stated that the value of
x[ 2 ] is 0. Doing a quick test with a sample debug program on Visual C++
6.0 affirms that the value of x[ 2 ] is 0. Is this a C++ standard directive
and am I wrong? Or was the test hogwash?
Thanks,
Mike