+ 4

Are negative array indices or 0 sized arrays valid in C++ ?

Why does this code compile and output 0? #include <iostream> using namespace std; int main() { int a[0]; cout << a[-1]; return 0; }

30th Mar 2019, 11:09 AM
Sonic
Sonic - avatar
1 Odpowiedź
+ 4
Thanks ~ swim ~. Personally I think they should not have compiler dependent questions in challenge quizzes but unfortunately we have some.
30th Mar 2019, 12:12 PM
Sonic
Sonic - avatar