I"m confused about his program that i wrote just to see what would happen:
Code:
#include <iostream.h>

int count = 0;
void func();


void main()
	{
	for(int j=0; j<10; j++)
		func();
	cout << "I have been excecuted " << count << " times.";
	}
void func()
	{
	count++;
	}
i wanted to see if 'j' would be reset to 0, and i expected it would have. But it wasn't. I thought automatic variables only keep their values and place in memory when the function which they are defined is called, and when excecution leaves the function the varibales are destroyed and their place in memory is no longer used. Why then would ''j' retain it's value. Doesn it has something to do with the loop that it's in?