FILE *fp[]; /* is this possible? */

Kim Christian Madsen kimcm at rimfaxe.diku.dk
Fri Nov 30 02:35:05 AEST 1990


weimer at ssd.kodak.com (Gary Weimer) writes:

>for(i=0;i!=256;i++)
>    if ((fp[i]=fopen(file_name[i],"r+")) <= 0)  /* some will probably     */
>                                                /* complain about using   */
>						 /* <= 0                   */

YES, for more than one reason:


	1) fopen returns a FILE * and should be tested against the constant
	   NULL, or (FILE *) NULL if you want explicit casting.

	2) If the pointer returned by fopen points to a memory location in
	   the high end it is very possible that when converted to an int
	   for the comparison it will be negative.

						Kim Chr. Madsen



More information about the Comp.lang.c mailing list