[comp.sys.sun] open vs. fopen

brent%sprite.Berkeley.EDU@ginger.berkeley.edu (Brent Welch) (12/21/88)

 ``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@ginger.Berkeley.EDU