Are declarations within an if statement illegal without an enclosing brace? For example:
if (argc == 2)
char* str = "Two";
else
char* str = "Not two";
Would need to be converted to:
if (argc == 2) {
char* str = "Two";
} else {
char* str = "Not two";
}
Out of curiosity, why is this so? I understand the need for braces with multiple statements such as:
if (something)
printf(something);
printf(something);
Where the above really "means" the following in lieu of explicit braeces:
if (something) {
printf(something);
}
printf(something);
But why is a single statement/declaration allowed, if it includes only a single ;?