[Courses] [C] Beginner's Lesson 4B: Arrays, Qualifiers, and Reading Numbers

Jenn Vesperman jenn at anthill.echidna.id.au
Sat Oct 12 06:57:50 EST 2002


On Sat, 2002-10-12 at 03:32, Eugene Teo wrote:
> u> C allows variables to be initialized in the declaration statement.
> 
> Note that 
> C _only_ allow variables to be declared at the beginning of the 
> function.

News to me.

Yes, it's -tradition- to declare your variables at the beginning of the
function, but it's possible to declare them at the start of any block:

#include <stdio.h>

int main() {

        printf("%s","Hello World\n");
        {
          int i = 5;
          printf("%d\n", i);
        }

}



Jenn V.
-- 
    "Do you ever wonder if there's a whole section of geek culture 
        	you miss out on by being a geek?" - Dancer.

jenn at anthill.echidna.id.au     http://anthill.echidna.id.au/~jenn/





More information about the Courses mailing list