[alt.msdos.programmer] Disk Full

emigh@ncsugn.ncsu.edu (Ted H. Emigh) (06/02/90)

Several people suggested ferror() as a way of checking for disk full.
Basically, this is the solution.  However, there are some things of which
to be careful.
1)	ferror() returns an error condition only when the buffer is flushed
	to disk.  For my floppy drives this is every 512 bytes.  An ferror()
	condition thus can refer to several fprintf's (or f...).  I presume
	this is universal behaviour for buffered prints.

2)	If the disk becomes full on the last buffer, then ferror() will not
	return an error condition on the f....  Instead, you should issue an
	fflush(fout).  If the disk is full (or other error), then this will
	return a nonzero number.  An ferror() after this will return the disk
	full message (0x10).  This can also be done with fclose(fout), but
	since fout is located on the heap, and fclose() frees the space, this
	is a riskier business.

-- 
Ted H. Emigh, Dept. Genetics and Statistics, NCSU, Raleigh, NC
uucp:	mcnc!ncsuvx!ncsugn!emigh	internet:  emigh@ncsugn.ncsu.edu
BITNET: emigh%ncsugn@MCNC.UUCP  or  emigh%ncsugn@ncsuvx.ncsu.edu