KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q39089: Using _gettextposition and printf.

Article: Q39089
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: 12-DEC-1988

When the C graphic routines are being used in a program, they should
be used for all output to the screen, including text output. Other C
run-time functions for output should not be used.

If a C program uses the run-time function _gettextposition, the
function _outtext should be used to output text to the screen. Using
the function printf will cause overwritting of text or blank lines to
be inserted on the video screen.

The following program will result in unpredictable output:

#include <stdio.h>
#include <stdlib.h>
#include <graph.h>

main()
{
   struct rccoord rcoord;
   system("cls");
   printf("11\n");
   printf("22222222\n");
   printf("333333\n");
   printf("fourth line\n");
   printf("fifth line\n");

   rcoord=_gettextposition();

   printf("6666\n");
   printf("77777777\n");
}

The work around is use _outtext instead of printf.

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.