4 ms·
> I want to have variables that only exist within an `if` block. That is something C99 got right. C89 allowed you to declare variables at the top of any block,
by trealira 3y ago
> I want to have variables that only exist within an `if` block. That is something C99 got right.
C89 allowed you to declare variables at the top of any block, not just functions, so you could declare variables that only exist within in if block. For example:
if (flag) {
int c;
while ((c = getchar()) != EOF) {
/* code */
}
}