My understanding is that an int variable will be initialized to 0 automatically; however, it is not. The code below prints a random value.
int main ()
{
int a[10];
int i;
cout << i << endl;
for(int i = 0; i < 10; i++)
cout << a[i] << " ";
return 0;
}
- What rules, if any, apply to initialization?
- Specifically, under what conditions are variables initialized automatically?