INF: Full Paths Need Double Backslashes in C

ID Number: Q34305

3.00 4.00 5.00 5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 5.0, 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version

7.0, the backslash (\) has a special meaning. Because of this, it must

be preceded by an additional backslash before it can be used as part of

a full path. For example, attempting to open an existing file in the

following manner will fail:

stream = fopen( "c:\c\source\test.c", "r" );

This is because the first argument is interpreted as a file named

C:CSOURCETEST.C in the current directory, rather than as a file named

TEST.C in the C:\C\SOURCE directory. The following example results in

the desired behavior:

stream = fopen( "c:\\c\\source\\test.c", "r" );

More Information:

The following functions are among those that may use a full path in an

argument:

access execv putenv spawnlp system

chdir execve remove spawnlpe tempnam

chmod execvp rename spawnv utime

creat execvpe rmdir spawnve _dos_creat

execl fopen _searchenv spawnvp _dos_creatnew

execle freopen sopen spawnvpe _dos_findfirst

execlp mkdir spawnl splitpath _dos_getfileattr

execlpe open spawnle stat _dos_open

_dos_setfileattr

Additional reference words: 5.00 5.10 6.00 6.00a 6.00ax 7.00