Microsoft KB Archive/42857

= C Escape Sequence Like &quot;\n&quot; Doesn't Function When Passed to C =

Article ID: 42857

Article Last Modified on 11/21/2006

-

APPLIES TO


 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft QuickBasic 4.5 for MS-DOS
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q42857



SUMMARY
When CALLing a C function from QuickBasic and passing a C-format string that contains C escape sequences, the escape sequence does not execute, but rather displays as part of the string. When the following example is used, the C &quot;\n&quot; escape sequence for carriage return/linefeed will not be executed from the C function as expected; the &quot;\n&quot; will simply be displayed as part of the string: FORMAT$ = &quot;number1= %d  number2= %d\n&quot; + CHR$(0) CALL CROUTINE(SADD(FORMAT$),LEN(FORMAT$) This information applies to QuickBasic Versions 4.00, 4.00b, and 4.50, to Microsoft Basic Compiler Versions 6.00 and 6.00b, and to Microsoft Basic PDS Version 7.00.



MORE INFORMATION
Escape sequences, such as &quot;\n&quot;, are replaced with the carriage return/linefeed characters when the C code is compiled. Therefore, if they are passed to a C program at run time, &quot;\n&quot; is not recognized as anything more than part of the string to be displayed.

For the C program to execute an escape sequence passed to it from a QuickBasic program, the actual characters for the desired operation must be appended to the passed string, as in the following example: FORMAT$ = &quot;number1= d%  number2= d%&quot; + CHR$(13) + CHR$(10) + CHR$(0) CALL CROUTINE(SADD(FORMAT$),LEN(FORMAT$) This passes the carriage return/linefeed sequence to the C function.

Additional query words: QuickBas BasicCom

Keywords: KB42857

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.