I don't understand why it is allowed to declare variables in a while or for loops. For example this is allowed (or at least compiles ??)
for(int i = 3; i > 0; i--) {
int d;
}
and this will give you a compiler error;
int d;
int d;
int d;
Why?? Is it just my compiler being kind (If it is soo, then I thin the compiler is too kind!) or is it legal for some other reason?