KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q66053: fputs() Fails with R6003 When Writing to STDAUX

Article: Q66053
Product(s): See article
Version(s): 6.00 6.00a
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist6.00 buglist6.00a | mspl13_c
Last Modified: 24-OCT-1990

The fputs() run-time library function will fail with the following
error when you try to put a string to STDAUX:

   run-time error R6003
   - integer divide by 0

Microsoft has confirmed this to be a problem in Microsoft C versions
6.00 and 6.00a. We are researching this problem and will post new
information here as it becomes available.

The following code demonstrates this error when compiled with the
default options:

#include <stdio.h>
void main (void)
{
   fputs("hello world\n", stdaux);
}

The fputs() function should have disabled buffering when dealing with
STDAUX, but it doesn't. To work around this problem, you can disable
buffering yourself by calling the setvbuf() function as follows:

   setvbuf(stdaux, NULL, _IONBF, 0);

The following code works correctly:

#include <stdio.h>
void main (void)
{
   setvbuf(stdaux, NULL, _IONBF, 0);
   fputs("hello world\n", stdaux);
}

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.