Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!udel!rochester!kodak!ispd-newsserver!weimer From: weimer@ssd.kodak.com (Gary Weimer) Newsgroups: comp.lang.c Subject: Re: FILE *fp[]; /* is this possible? */ Message-ID: <1990Nov28.152146.19560@ssd.kodak.com> Date: 28 Nov 90 15:21:46 GMT References: <1990Nov27.131327.21662@agate.berkeley.edu> Sender: news@ssd.kodak.com Organization: Eastman Kodak Lines: 24 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) As others have mentioned, you are probably getting (nil) because fopen() is failing (most likely because you are opening too many files). If you want to know the specific reason for the failure, or just be notified when such a failure occurs, try using: for(i=0;i!=256;i++) if ((fp[i]=fopen(file_name[i],"r+")) <= 0) /* some will probably */ /* complain about using */ /* <= 0 comparison */ { perror("Error opening file"); /* this will print: */ /* "Error opening file: REASON" */ /* put error handler here, or just exit program */ }