INF: The Function fopen Accepts Filenames with Embedded Spaces

ID Number: Q43073

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

The Microsoft run-time library functions fopen() and open() do not

screen for invalid filenames. These functions accept a filename string

with an embedded space. For example, the following program creates the

file "he llo.dat" (without the quotation marks).

This error is not the result of a problem with fopen() or open(). The

functions fopen() and open() should not be expected to screen

filenames. This activity should be handled by the program using these

routines. Filename screening is not specified in the "Microsoft C

Optimizing Compiler: Run-Time Library Reference" manual; this applies

to both MS-DOS and OS/2.

However, the creation of this file may cause some difficulties under

MS-DOS. The simplest way to delete such a file is "del *.dat" (without

the quotation marks).

Sample Code

-----------

#include <stdio.h>

FILE *fh;

void main(void)

{

fh = fopen ("he llo.dat", "w+");

fclose(fh);

}

Additional reference words: 2.00 2.01 2.50 2.51 6.00 6.00a 6.00ax 7.00

quickc