Re: Why this Code Works ??

Discussion in 'C Programming' started by Chris Mears, Jun 30, 2003.

  1. Chris Mears

    Chris Mears Guest

    (James) writes:

    > int a ;
    > int a ;
    >
    > main ( ) {
    > a = 94 ;
    > printf ("%d\n", a) ;
    > }
    >
    > Why does this code compile without any warning.
    > If u initialise a. It is an error ?. Why ?.


    It works because there is no reason for it not to work. If you include
    an initialiser with one of the declarations then that declaration
    becomes a definition (rather than just a tentative definition). If you
    try to initialise the object with both declarations you end up with two
    definitions, which is illegal.

    --
    Chris Mears
    Chris Mears, Jun 30, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. F. GEIGER
    Replies:
    3
    Views:
    756
    F. GEIGER
    Aug 6, 2004
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    863
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,762
    Smokey Grindel
    Dec 2, 2006
  4. Alexander Burger

    getMethod() works and works not

    Alexander Burger, Nov 27, 2010, in forum: Java
    Replies:
    25
    Views:
    1,722
    Alexander Burger
    Nov 29, 2010
  5. abargaddon
    Replies:
    1
    Views:
    187
    clintmazur
    Feb 4, 2008
Loading...

Share This Page