KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q29281: Using printf() with Far Pointers in Small Model Programs

Article: Q29281
Product(s): See article
Version(s): 3.00 4.00 5.00 5.10 6.00 6.00a | 5.10 6.00 6.00a
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | s_quickc | mspl13_c
Last Modified: 15-JAN-1991

Problem:

I have a number of far pointers pointing to various data items in my
program. I compiled the program in the small-memory model. However,
printf() will not return the data to the area in which the pointers
are pointing.

Response:

To use printf() to print data items (strings and pointers only) that
have been declared as far in a small- or medium-memory model, use F to
modify the %s or %p field. For example, if you have the following
declaration

   char far *ptr;

you can print out the value of the pointer with the following call:

   printf("%Fp",ptr);

You also can print out the string pointed to by ptr (assuming that it
has been initialized in your code) with the following call:

   printf("%Fs",ptr);

For additional information on the use of the F specifier with
printf(), refer to the  C run-time library reference or online help
that was supplied with your particular version of the compiler.

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.