Microsoft KB Archive/76664

{|
 * width="100%"|

PRB: freopen Function Fails in QuickWin Libraries

 * }

Q76664

7.00 | 1.00 1.50 MS-DOS | WINDOWS kbprg kbprb -- The information in this article applies to: - The C Run-time (CRT), included with: - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, versions 1.0 and 1.5 -- SYMPTOMS ======== The freopen function in the Microsoft C run-time library fails if an application attempts to reassign stdin, stdout, or stderr in a QuickWin window. The sample code below demonstrates this behavior. CAUSE ===== This limitation is caused by a design restriction in the QuickWin implementation. QuickWin does not supporting stdin, stdout, or stderr (unlike MS-DOS and OS/2). Because QuickWin assigns all three standard streams to the same file handle, closing one stream affects the others. In MS-DOS and OS/2, each stream has its own file handle that the application can manipulate without affecting the other streams. RESOLUTION ========== Do not reassign stdin, stdout, or stderr while in a QuickWin window. MORE INFORMATION ================ Sample Code --- /* Compile options needed: QuickWin EXE */ #include #include FILE *stream, *errstream; void main(void) { /* Reassign &quot;stdout&quot; to &quot;data2&quot; */ stream = freopen(&quot;data2&quot;, &quot;w&quot;, stdout); if (stream == NULL ) /* If reassignment failed */ printf(&quot;error on freopen\n&quot;); else { fprintf(stream,&quot;This will go to the file `data2'\n&quot;); printf(&quot;`stdout' successfully reassigned\n&quot;); fclose(stream); } exit(0); } Additional reference words: 1.00 1.50 7.00 KBCategory: kbprg kbprb KBSubcategory: CRTIss

Keywords : kb16bitonly

Issue type :

Technology : kbVCsearch kbAudDeveloper kbCRT