The information in this article applies to:
SUMMARYIn Microsoft C for MS-DOS and Windows NT, if you enter the escape character (ASCII 1Bh) from the keyboard (console) into a string that gets(), cgets(), or fgets() is reading, all the string previously read in is erased. The string pointer is reset so that characters following the escape character are read into the beginning of the string. This is consistent with the action taken by the operating system to parse the input line. However, if the escape character is input from a file by redirection, the entire string, including the escape character, will be read into the string. MORE INFORMATIONSample Code #1
Enter the following string as a test:
Note that the resulting string is output as:
Now, create a data file named test.dat containing the string
"abcdef<esc>ghijk" either by using a text editor that permits escape
characters to be embedded in a string or by using the sample code #2
below.
Sample Code #2
If the program from sample code #1 is run with input redirected from
the data file, as follows:
the resulting string is output as follows:
This behavior occurs in the entire gets() family of routines,
including gets(), cgets(), and fgets(). If the input is coming from
the console, the run time will use the standard MS-DOS, OS/2, or
Windows NT keyboard read routines. On the other hand, if the input is
coming from a file (through redirection), the operating system doesn't
perform any editing and the file is read in literally.
Additional query words:
Keywords : kbcode kbCRT kbVC100 kbVC150 kbVC200 kbVC210 kbVC400 kbVC500 kbVC600 |
Last Reviewed: July 1, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |