FILE *fp[]; /* is this possible? */
Don Miller
donm at margot.Eng.Sun.COM
Thu Nov 29 11:06:18 AEST 1990
In article <1990Nov27.131327.21662 at agate.berkeley.edu> labb-4ac at 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 <std.disclaimer>
Software Quality Engineering | #define flame_retardent \
Sun Microsystems, Inc. | "I know you are but what am I?"
donm at eng.sun.com |
More information about the Comp.lang.c
mailing list