Skip to content

C/C++/Java – Leading 0 (zero) means Octal

Accidentally prefixed a 0 in front of a variable, and as it turns out prefixing a integer value with 0 means it is an Octal.

Try this:

#include <stdio.h>

int a = 0134;

int main() {
    printf("%d", a);

    return 0;

The result is 92

This is the same across C/C++/Java

Posted in C/C++, Java. Tagged with , , , .