PRB: Changing STDIN Translation Mode from Text to Binary (58427)
The information in this article applies to:
- The C Run-Time (CRT), when used with:
- Microsoft C for MS-DOS 5.1
- Microsoft C for MS-DOS 6.0
- Microsoft C for MS-DOS 6.0a
- Microsoft C for MS-DOS 6.0ax
- Microsoft C/C++ for MS-DOS 7.0
- Microsoft Visual C++, 32-bit Professional Edition 2.0
This article was previously published under Q58427 SYMPTOMS
In Microsoft C, when a ^Z (CTRL+Z) is entered as part of a string
input in response to gets() or scanf(), the next line does not prompt
for an input.
CAUSE
Because STDIN is a predefined file pointer opened in text mode, and a
^Z character is an end-of-file marker in MS-DOS, the ^Z character
automatically closes the file pointer. The gets() or scanf() function
does not stop to accept input from STDIN following the previous input
containing a ^Z character.
RESOLUTION
To work around this problem, change the translation mode of STDIN from
text mode to binary mode. Because the ^Z character is not translated
as an end-of-file character in binary mode, the gets() from the
following example accepts input only following a ^Z from STDIN after
the translation.
Modification Type: | Major | Last Reviewed: | 12/11/2003 |
---|
Keywords: | kbCRT kbprb KB58427 |
---|
|