open vs. fopen

Brent Welch brent%sprite.Berkeley.EDU at ginger.berkeley.edu
Wed Dec 21 08:43:58 AEST 1988


 ``you can call "open" with only the file name as the argument ...
   (I called it with "r" though)''

fopen and open take different parameters.

	open(filename, flag_bits, permissions)
	fopen(filename, flag_string)

The second argument to open is something like O_RDONLY, or
O_WRONLY|O_TRUNC, while the second argument to fopen is something like
"r", or "w".  The C language does no type checking so you can easily screw
up this way.  It is likely that the pointer value passed for "r" contained
the O_TRUNC bit...  [[ Use lint.  --wnl ]]

	Brent Welch
	University of California, Berkeley
	brent%sprite at ginger.Berkeley.EDU



More information about the Comp.sys.sun mailing list