KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q43809: Changes in scanf() and printf() for Long Types in C

Article: Q43809
Product(s): See article
Version(s): 5.10   | 5.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | S_QuickC | mspl13_c
Last Modified: 19-SEP-1989

As of Version 5.10 of the Microsoft C Optimizing Compiler and Version
1.00 of the QuickC compiler, the scanf() and printf() functions no
longer support the uppercase D, O, and I type characters, which
represented long-integer fields.

Current versions of Microsoft C compilers precede the type characters
in the format portion of the printf() and scanf() functions with an
"l"  (lowercase letter "l") to specify long-type fields.

The uppercase "X" format specifier also has been changed; it now
specifies that uppercase letters are to be used when displaying
hexadecimal numbers in a printf() statement.

The following code fragment reads an integer into a variable and then
displays the value of the variable:

int i;
scanf( "%d", &i );
printf( "%d", i );

The following code fragment accepts and displays the value of a long
integer variable:

long i;
scanf( "%ld", &i );
printf( "%ld", i );

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.