...
Code Block |
---|
char msg[100];
{
char msg[80] = "Hello";
strcpy(msg, "Error");
}
printf ("%s\n", msg);
|
Compliant Solution
...
Code Block |
---|
char error_msg[100]; { char hello_msg[80] = "Hello"; strcpy(error_msg, "Error"); } printf ("%s\n", error_msg); |
Exceptions
When the block is small, the danger of reusing variable names is mitigated by the visibility of the immediate declaration. Even in this case, however, variable name reuse is not desirable.
...