It might be a boring question! thanks!
Here's the code:
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
int a[5] = {0};
int b[5];
cout << a << endl;
cout << b << endl;
for (int i = 0; i < 5; i++)
{
cout << a[i] << " ";
}
cout << endl;
for (int i = 0; i < 5; i++)
{
cout << b[i] << " ";
}
cout << endl;
return 0;
}
in Ubuntu: g++ a.cpp
In windows with DEV C++ ,MinGW GCC 4.7.2:
So the question is focused on the array b:
I know I haven't initialized the array b.
Array b is full of garbage values, but why there is always having '0' with the fixed position like "X 0 X 0 X"??
What happens inside??
Just a protection mechanism?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…