06.08.2013 Views

pSOSystem System Calls - Read

pSOSystem System Calls - Read

pSOSystem System Calls - Read

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

fclose pREPC+ <strong>System</strong> <strong>Calls</strong><br />

fclose Closes a stream.<br />

#include <br />

#include <br />

int fclose(<br />

FILE *stream /* stream pointer */<br />

)<br />

Description<br />

Arguments<br />

Return Value<br />

Error Codes<br />

The fclose() function first flushes the buffer associated with the stream pointed<br />

to by stream and closes the associated file or I/O device. Any unwritten buffered<br />

data is written to the associated file or I/O device, and any unread buffered data is<br />

discarded. The stream is disassociated from the file or I/O device.<br />

If the buffer was automatically allocated when the stream was opened, it is<br />

reclaimed by the system. The user is responsible for returning user-supplied<br />

buffers.<br />

When invoked with a null stream pointer, fclose() has a special significance<br />

under pREPC+. It causes pREPC+ to:<br />

■ Close all streams opened by the calling task.<br />

■ Reclaim all memory allocated by pREPC+ on behalf of the calling task, either<br />

implicitly or explicitly by calls to malloc() or calloc() functions.<br />

stream Points to an open pREPC+ stream.<br />

This function returns 0 if successful or end-of-file (EOF) if an error occurs. If an<br />

error occurs, errno is set.<br />

Refer to Appendix B.<br />

3-30 <strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!