I found a very strange c++ code.
Can someone explain the for-loop condition for me?
How come it just has an array and index variable?
include <iostream>
using namespace std;
int main()
{
int a[] = {1, 2, 3, 4, 5};
for (int i = 0; a[i];i++){
cout << a[i] << endl;
}
return 0;
}
The result is:
1
2
3
4
5
-858993460
2424376
12655176
1
3492888
3483368
1402216725
Why does it output 12 elements? Where are those additional 7 elements from? Many Thanks!