Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!uakari.primate.wisc.edu!dali.cs.montana.edu!milton!ogicse!intelhf!ichips!inews!cmdnfs!bhoughto From: bhoughto@cmdnfs.intel.com (Blair P. Houghton) Newsgroups: comp.lang.c Subject: Re: FILE *fp[]; /* is this possible? */ Message-ID: <1101@inews.intel.com> Date: 27 Nov 90 16:15:19 GMT References: <1990Nov27.131327.21662@agate.berkeley.edu> Sender: news@inews.intel.com Organization: Intel Corp, Chandler, AZ Lines: 33 In article <1990Nov27.131327.21662@agate.berkeley.edu> labb-4ac@e260-2a.berkeley.edu (superMan (the web dweller)) writes: >I have the following > >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) How big is `i'? If it's over 63, you're likely to have a problem. On older machines, the maximum is 19 (i.e., only 20 file descriptors allowed). 1. Find out what standard header file on your system defines the number of file descriptors you may use. (Usually it will be defined in stdio.h). 2. Find out what the macro is called (Under Ultrix 3.1 it's _NFILE). 3. Include the header. 4. Replace `256' with the macro everywhere. 5. Avoid trying to access beyond the end of the array (on some systems it's a core-dumping segmentation violation). There's nothing wrong with using an array of file pointers instead of unarrayed file pointers. --Blair "Currently working on an in-circuit emulator for the Milton-Bradley game, 'Operation.' Bzzzt! :-)"