CodeView Versions 2.x Use Four Extra File Handles

ID Number: Q25950

2.00 2.10 2.20 2.30 2.35

MS-DOS

Summary:

CodeView versions 2.0, 2.1, 2.2, 2.3, and 2.35 use four additional

file handles over the standard five preopened by DOS.

In the sample code below, the program attempts to open 20 files,

reporting its success or failure after each attempt. Running outside

of CodeView, the call to fopen() fails after 15 streams have been

opened. Running in CodeView versions 1.x or 3.x, the fopen() call also

fails after 15 files have been opened. However, in CodeView versions

2.x, the call fails after 11 file handles have been opened.

CodeView version 2.0, 2.1, 2.2, 2.3, or 2.35 requires the four extra

file handles for its own use. If you want to open more than 15 files,

follow the steps specified in the C version 5.1 or 6.0 README.DOC to

modify the C start-up code to allow opening more than 20 files.

Sample Code

-----------

/* Compile options needed: /Zi /Od

*/

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

void main()

{

FILE *streams[20];

int i;

char buffer[12];

char *p;

for (i = 0; i < 20; i++) {

p = itoa(i, buffer, 10);

p = strcat(buffer, ".dat");

streams[i] = fopen(buffer, "w+");

printf("streams[%d] = %d\n", i, streams[i]);

}

}