TC Compiler behaving unintended

Discussion in 'C' started by go4expert, Aug 9, 2004.

  1. go4expert

    go4expert Moderator

    Joined:
    Aug 3, 2004
    Messages:
    306
    Likes Received:
    9
    Trophy Points:
    0
    Hello All

    There are 2 code snippets
    Code:
    main()
    {
    int a=3;
    printf("%d \t%d\t %d",a);
    }
    
    TC Output 3 3 0
    GCC Output 3 0 garbage
    Code:
    main()
    {
    long int a=3;
    printf("%d \n%d\n %d",a);
    }
    
    Output 3 0 3
    GCC Output 3 0 garbage

    can anyone explain why this unintended behaviour if both the compilers.
     
  2. alok

    alok New Member

    Joined:
    Jul 24, 2004
    Messages:
    127
    Likes Received:
    2
    Trophy Points:
    0
    Occupation:
    S/W Engg
    Home Page:
    http://www.thatsalok.com
    hain ,
    that the internal working of compiler how to treat the %d in scanf.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice