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

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:
    7
    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:
    hain ,
    that the internal working of compiler how to treat the %d in scanf.
     

Share This Page