Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!sun!exodus!margot.Eng.Sun.COM!donm From: donm@margot.Eng.Sun.COM (Don Miller) Newsgroups: comp.lang.c Subject: Re: FILE *fp[]; /* is this possible? */ Summary: mode problem Keywords: fopen mode Message-ID: <3651@exodus.Eng.Sun.COM> Date: 29 Nov 90 00:06:18 GMT References: <1990Nov27.131327.21662@agate.berkeley.edu> Sender: news@exodus.Eng.Sun.COM Organization: Sun Microsystems, Mt. View, Ca. Lines: 22 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) Interesting threads regarding maximum open files notwithstanding, it seems that a simple answer to the original question posed is the mode is wrong. If the files to be opened do not exist prior to the fopen call, using fopen with "r+" will return 0 (nil, NULL). Try "w+" to open a new file for update. Since "w+" overwrites files, you'll want to be careful. You may want to use what you have to verify the non-existence before you use "w+". -- Don Miller | #include Software Quality Engineering | #define flame_retardent \ Sun Microsystems, Inc. | "I know you are but what am I?" donm@eng.sun.com |