FILE *fp[]; /* is this possible? */

Lars Wirzenius wirzeniu at cs.Helsinki.FI
Wed Nov 28 05:54:07 AEST 1990


In article <1990Nov27.131327.21662 at agate.berkeley.edu> 
	labb-4ac at e260-2a.berkeley.edu (superMan (the web dweller)) writes:
>FILE *fp[256];
>for(i=0;i!=256;i++) fp[i]=fopen(file_name[i],"r+");
>but when I look at the value of fp[i] I get (nil)

I think the problem is that you've hit on the maximum number of open
files per program in your system. The limit may be set by either the
operating system, the C library or both. For example, on MS-DOS using
Turbo C the limit is 20 open files at once. In ANSI-systems the macro
FOPEN_MAX (defined in <stdio.h>) tells the maximum number of files that
you can have open simultaneously.

You can try to get around this by keeping the files open only when you
need them. You might want to save the "current place" before you close a
file, and restore it after you re-open it.

Lars Wirzenius    wirzeniu at cs.helsinki.fi    wirzenius at cc.helsinki.fi



More information about the Comp.lang.c mailing list