PRB: fputs() Fails with R6003 on Write to stdaux

ID Number: Q66053

6.00 6.00a 6.00ax

MS-DOS

buglist6.00 buglist6.00a buglist6.00ax fixlist7.00

Summary:

SYMPTOMS

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

STATUS

Microsoft has confirmed this to be a problem in C versions 6.0,

6.0a, and 6.0ax. This problem was corrected in C/C++ version 7.0.

More Information:

The sample code below demonstrates this error when compiled with the

default options. The fputs() function should disable 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);

In the sample program below, uncommenting the call to setvbuf() will

eliminate the R6003 error.

Sample Code

-----------

/* Compile options needed: none

*/

#include <stdio.h>

void main (void)

{

/* Uncomment the following line to eliminate the R6003 error */

/* setvbuf(stdaux, NULL, _IONBF, 0); */

fputs("hello world\n", stdaux);

}