query!!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agsupriya86
    New Member
    • Mar 2007
    • 34

    query!!

    Hello,

    Can anybody explain me the difference between 0123 and 123 in C??

    I read somewhere its saying 40..how???
  • scruggsy
    New Member
    • Mar 2007
    • 147

    #2
    Originally posted by agsupriya86
    Hello,

    Can anybody explain me the difference between 0123 and 123 in C??

    I read somewhere its saying 40..how???
    If you add a leading 0 to an integer, the compiler reads it in octal (base-8) notation.
    Code:
    int dec = 10; // dec = 10 in decimal
    int oct = 010; // oct = 8 in decimal
    But 123 in octal is not 40.
    Hope this helps.

    Comment

    Working...