Microsoft KB Archive/35037: Difference between revisions

From BetaArchive Wiki
m (Text replacement - "<" to "<")
m (Text replacement - ">" to ">")
 
Line 68: Line 68:
== MORE INFORMATION ==
== MORE INFORMATION ==


All character constants of the form &quot;\<o&gt;&quot;, &quot;\<o&gt;<o&gt;&quot;, &quot;\<o&gt;<o&gt;<o&gt;&quot;, (where <o&gt; is a digit) and their string equivalents are specified in octal as well. For example, \33 and \033 each specify the ESC character (decimal 27, hexadecimal 1B). To specify a character constant in hexadecimal, use &quot;\x<h&gt;<h&gt;&quot;, where <h&gt; is a hexadecimal digit. C does not provide a method to specify a decimal number in a character constant; you can use a decimal integer constant instead (for example, ch = 27).
All character constants of the form &quot;\<o>&quot;, &quot;\<o><o>&quot;, &quot;\<o><o><o>&quot;, (where <o> is a digit) and their string equivalents are specified in octal as well. For example, \33 and \033 each specify the ESC character (decimal 27, hexadecimal 1B). To specify a character constant in hexadecimal, use &quot;\x<h><h>&quot;, where <h> is a hexadecimal digit. C does not provide a method to specify a decimal number in a character constant; you can use a decimal integer constant instead (for example, ch = 27).


</div>
</div>

Latest revision as of 10:19, 21 July 2020

Knowledge Base


INFO: How C Interprets Integer Constants with Leading Zeroes

Article ID: 35037

Article Last Modified on 12/11/2003



APPLIES TO

  • Microsoft Visual C++ 1.0 Professional Edition
  • Microsoft Visual C++ 1.5 Professional Edition
  • Microsoft Visual C++ 1.51
  • Microsoft Visual C++ 1.52 Professional Edition
  • Microsoft Visual C++ 2.0 Professional Edition
  • Microsoft Visual C++ 2.1
  • Microsoft Visual C++ 4.0 Standard Edition
  • Microsoft Visual C++ 5.0 Enterprise Edition
  • Microsoft Visual C++ 6.0 Enterprise Edition
  • Microsoft Visual C++ 5.0 Professional Edition
  • Microsoft Visual C++ 6.0 Professional Edition
  • Microsoft Visual C++ 6.0 Standard Edition



This article was previously published under Q35037

SUMMARY

Two similar assignment statements produce very different results when the application prints values assigned. For example:

   a = 20;
   printf("%d", a);   /* this prints "20" */ 
   a = 020;
   printf("%d", a);   /* but this prints "16" */ 
                

Any number with a leading "0" (zero) is interpreted to be an octal number (base 8). Remove the leading zero from the decimal number.

MORE INFORMATION

All character constants of the form "\<o>", "\<o><o>", "\<o><o><o>", (where <o> is a digit) and their string equivalents are specified in octal as well. For example, \33 and \033 each specify the ESC character (decimal 27, hexadecimal 1B). To specify a character constant in hexadecimal, use "\x<h><h>", where <h> is a hexadecimal digit. C does not provide a method to specify a decimal number in a character constant; you can use a decimal integer constant instead (for example, ch = 27).

Keywords: kbinfo kblangc KB35037