1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Why does one work and other does not....

Discussion in 'C' started by An007kit, Oct 2, 2007.

  1. An007kit

    An007kit New Member

    Joined:
    Oct 1, 2007
    Messages:
    15
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    Am a student
    Location:
    Live in chandigarh, india
    These are the two codes...
    a)
    Code:
    #include<stdio.h>
    int i=5;
    void main()
    {
    int i=6;
    printf("%d",i);
    }
    output = 6
    b)
    Code:
    #include<stdio.h>
    void main()
    {
    extern int i;
    int i=6
    printf("%d",i);
    }
    int i=5;
    output=ERROR
     
    Last edited by a moderator: Oct 2, 2007
  2. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    Read up on scope. Learn to put your code in code tags.
     

Share This Page