Mono Class Library: Mono.Unix.Native.Stdlib Overview | Members

Mono.Unix.Native.Stdlib.fgets Method

Read a line from a FILE stream. [Edit]

public static System.Text.StringBuilder fgets (System.Text.StringBuilder sb, int size, IntPtr stream)

Parameters

sb
Where to store the next line of text from stream. [Edit]
size
The maximum number of characters that sb can hold. [Edit]
stream
The FILE stream to read a line from. [Edit]

Returns

Upon successful completion, returns sb. If end-of-file occurs before any characters are read, returns null and the contents of sb remains unchanged. If an error occurs, null is returned and the contents of sb are indeterminate. fgets does not distinguish between end-of-file and error, and callers must use Stdlib.feof(3) and Stdlib.ferror(3) to determine which occurred.

Usage

The following errors are specified:

ErrorDetails
Errno.EBADFThe given stream is not a readable stream.

fgetpos may also fail for any of the error specified for the routines Stdlib.fflush(3), Syscall.fstat(2), Syscall.read(2), or Stdlib.malloc(3).

[Edit]

Remarks

The fgets() function reads at most one less than the number of characters specified by size from the given stream and stores them in the string sb. Reading stops when a newline character is found, at end-of-file or error. The newline, if any, is retained. If any characters are read and there is no error, a '\0' character is appended to end the string. [Edit]

Requirements

Namespace: Mono.Unix.Native
Assembly: Mono.Posix (in Mono.Posix.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0