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.

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

fgets Gets a string from a stream.<br />

#include <br />

#include <br />

char *fgets(<br />

char *s, /* buffer */<br />

int n, /* length */<br />

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

)<br />

Description<br />

Arguments<br />

Return Value<br />

Error Codes<br />

The fgets() function reads at most one less than the number of characters<br />

specified by n from the stream pointed to by stream. The characters go into the<br />

user buffer pointed to by s. The function stops reading characters when a new-line<br />

character (which is retained) or an end-of-file condition is detected. A null character<br />

is written immediately after the last character is read into the user buffer.<br />

If stream references a disk file, its position indicator is advanced.<br />

s Points to the user buffer where fgets() stores characters.<br />

n Specifies the number of characters to read, plus one for the<br />

null terminator.<br />

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

This function returns s if successful. If a read error occurs or an end-of-file<br />

condition is detected before any characters are read, a null pointer is returned and<br />

errno is set.<br />

Refer to Appendix B.<br />

<strong>pSO<strong>System</strong></strong> <strong>System</strong> <strong>Calls</strong> 3-37<br />

3

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

Saved successfully!

Ooh no, something went wrong!