Monday 7 November 2011

How can I have more than 20 files open at once? in C programming

How can I have more than 20 files open at once?

The DOS configuration file, CONFIG.SYS, usually contains a FILES entry that tells DOS how many file
handles to allocate for your programs to use. By default, DOS allows 20 files to be open at once. In many
cases, especially if you are a user of Microsoft Windows or a database program, 20 file handles is not nearly
enough. Fortunately, there is an easy way to allocate more file handles to the system. To do this, replace your
FILES= statement in your CONFIG.SYS file with the number of file handles you want to allocate. If your
CONFIG.SYS file does not contain a FILES entry, you can append such an entry to the end of the file. For
example, the following statement in your CONFIG.SYS file will allocate 100 file handles to be available for
system use:

FILES=100

On most systems, 100 file handles is sufficient. If you happen to be encountering erratic program crashes,
you might have too few file handles allocated to your system, and you might want to try allocating more file
handles. Note that each file handle takes up memory, so there is a cost in having a lot of file handles; the more
file handles you allocate, the less memory your system will have to run programs. Also, note that file handles
not only are allocated for data files, but also are applicable to binary files such as executable programs.

Cross Reference:

None.

No comments:

Post a Comment