Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!usc!ucsd!ucbvax!bloom-beacon!eru!hagbard!sunic!news.funet.fi!hydra!kreeta!wirzeniu From: wirzeniu@cs.Helsinki.FI (Lars Wirzenius) Newsgroups: comp.lang.c Subject: Re: FILE *fp[]; /* is this possible? */ Summary: Can't have 256 files open at once. Message-ID: <9704@hydra.Helsinki.FI> Date: 27 Nov 90 18:54:07 GMT References: <1990Nov27.131327.21662@agate.berkeley.edu> Sender: news@cs.Helsinki.FI Organization: University of Helsinki, Department of Computer Science Lines: 18 In article <1990Nov27.131327.21662@agate.berkeley.edu> labb-4ac@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 ) 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@cs.helsinki.fi wirzenius@cc.helsinki.fi