Microsoft KB Archive/63322

= Microsoft Knowledge Base =

C Regards the Right Arrow Character (1Ah) as End of File
Last reviewed: July 22, 1997

Article ID: Q63322

6.00 6.00a 6.00ax 7.00 | 6.00 6.00a | 1.00 1.50 | 1.00 2.00 4.00

MS-DOS                | OS/2       | WINDOWS   | WINDOWS NT kbtool kbfasttip

The information in this article applies to:

The Microsoft C/C++ Compiler (CL.EXE) included with: - Microsoft C for MS-DOS, versions 6.0, 6.0a, and 6.0ax - Microsoft C for OS/2, versions 6.0, and 6.0a - Microsoft C/C++ for MS-DOS, version 7.0 - Microsoft Visual C++ for Windows, version 1.0 and 1.5 - Microsoft Visual C++ 32-bit Edition, versions 1.0, 2.0, and 4.0

SUMMARY
In Microsoft C, the right arrow character (1Ah) is read as an end-of-file (EOF) character, even if it occurs nested within a character string.

The unexpected EOF can be avoided by inserting an escape sequence within the string to replace the right arrow character. Use the following

printf(&quot;Hello&quot;&quot;\x1a&quot;&quot;world.&quot;); instead of:

printf(&quot;Hello(right arrow character)world&quot;); Using the proper format forces the compiler to recognize the hex 1A as an escape sequence, instead of an EOF. If the escape sequence is not separated from the rest of the string, it may be read as a different hex value, because characters will appear directly after it. In addition to hex values, an octal value may be used.