Variable declaration placement in C

It compiles successfully because GCC allows the declaration of s as a GNU extension, even though it’s not part of the C89 or ANSI standard. If you want to adhere strictly to those standards, you must pass the -pedantic flag.

The declaration of c at the start of a { } block is part of the C89 standard; the block doesn’t have to be a function.

Leave a Comment