What is the difference between 15 and 015?

c++, char, output

Solution

No, 015 refers to octal number. So, 015 in octal is equal to 13 in decimal.

So,

char f_gear = 015;

is equivalent to

char f_gear = 13;

Problem

This might be appear to be a silly/trivial question at first, but when I do this: ``` char f_gear = 15; ``` I get the normal output ``` "☼" ``` but when I pad it with zeros when i declare it: ``` char f_gear = 015; ``` I get weird output makes text look garbled (in one line) and blanks the previous line. When I attempt to see the individual character itself, I get the following: ``` "  ◘◘@╧S☻ " ``` What is essentially different? Isn't 15==015? ==EDIT== Stack Overflow changed the text when I posted the question. The output I really saw was a few blank characters.

Original source

Related problems