[From "Writing Solid Code" by Steve McQuire]
Look at the following code and answer the following question.
while (expression)
{
int i = 33;
char str[20];
... // more code
}
"Quick! Is i initialized each time through the loop, or only the first time the loop is entered? If you're not sure you are in good company -- even expert programmers usually pause for a few moments as they mentally scan C's initializer rules."
Maybe the following is a bit clearer
while (expression)
{
int i;
char str[20];
I = 33;
... // more code
}
"Programmers frequently forget that they have two audiences: the customers who use the code and the maintenance programmers who have to update the code."