Simple ptr passing question

Doug Gwyn gwyn at smoke.brl.mil
Thu May 16 07:35:01 AEST 1991


In article <13012 at uhccux.uhcc.Hawaii.Edu> morrison at uhhacb.tmc.edu (Jay Morrison) writes:
>The problem is that in C you always pass by reference, ...

No, it's always pass by value, which agrees with the further description
you gave.

>Another common problem you may encounter is a returning a FILE*
>structure from a routine which opens a file.  In this situation you must
>also use pointers to pointers.  This even had my professor confused as
>to what was happening!! (temporarily).

The standard practice for such a function is to make the FILE* its
return value, e.g.
	extern FILE *my_open( const char *name );
with a null pointer being returned when the function fails.



More information about the Comp.lang.c mailing list