CrazyEngineers
  • Vishal
    Vishal

    MemberSep 17, 2013

    confusing C question

    Can anyone explain me why, i is considered as an octal number in this code?


    #include
    int main() {
    int i = 0100;
    printf("%d",i);
    }
    Replies
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • Jeffrey Arulraj

    MemberSep 17, 2013

    Simple

    The first letter '0' indicate the compiler that the number is an OCTAL number
    '0x' indicates Hexa decimal number
    Are you sure? This action cannot be undone.
    Cancel
  • Vishal Sharma

    MemberSep 17, 2013

    Jeffrey Samuel
    Simple

    The first letter '0' indicate the compiler that the number is an OCTAL number
    '0x' indicates Hexa decimal number
    and 0b for binary... Its same like MCU's 😛 didn't think in that way! thanks!
    Are you sure? This action cannot be undone.
    Cancel
  • Jeffrey Arulraj

    MemberSep 17, 2013

    Vishal0203
    and 0b for binary... Its same like MCU's 😛 didn't think in that way! thanks!
    It seems '0b' will do that for you mate
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register