INFO: Full Paths Need Double Backslashes in CLast reviewed: August 26, 1997Article ID: Q34305 |
The information in this article applies to:
SUMMARYIn C, the backslash character (\) has a special meaning to treat the next character as a literal value or to create an escape sequence, such as the end-of-line indicator (\n). Therefore, you must use two sequential backslashes to separate the directory name from the file name in a path specification. For example, consider an attempt to open a file with the following code:
stream = fopen( "c:\c\source\test.c", "r" );This code fails because the fopen() function receives "C:CSOURCETEST.C" as its first argument. The function attempts to open a file in the current directory rather than opening the TEST.C file in the C:\C\SOURCE directory. The following code example creates the desired behavior:
stream = fopen( "c:\\c\\source\\test.c", "r" ); MORE INFORMATIONThe following C run-time library routines can accept a fully qualified path as an argument:
*_dos_creat chmod execvpe sopen splitpath *_dos_creatnew creat fopen spawnl stat *_dos_findfirst execl freopen spawnle system *_dos_getfileattr execle mkdir spawnlp tempnam *_dos_open execlp open spawnlpe utime *_dos_setfileattr execlpe putenv spawnv _searchenv execv remove spawnve access execve rename spawnvp chdir execvp rmdir spawnvpe * indicates the function is available only with 16-bit implemetations.Keywords : CLngIss Version : MS-DOS:5.1,6.0,6.00a,6.00ax,7.0; WINDOWS:1.0,1.5; WINDOWS NT:1.0,2.0,4.0,5.0 Platform : MS-DOS NT WINDOWS Issue type : kbinfo |
================================================================================
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |