gets


Description:

[ CCode ( cname = "fgets" , instance_pos = -1 ) ]
public unowned string? gets (char[] s)

Reads at most s.length - 1 characters from the given file stream and stores them in s.

The produced character string is always null-terminated. Parsing stops if end-of-file occurs or a newline character is found, in which case str will contain that newline character.

Example: Read chars from a stream:

public static int main (string[] args) {
// Opens "foo.txt" for reading ("r")
FileStream stream = FileStream.open ("filestream.vala", "r");
assert (stream != null);

// buffered:
char buf[100];
while (stream.gets (buf) != null) {
print ((string) buf);
}

return 0;
}

valac --pkg glib-2.0 GLib.FileStream.gets.vala

Parameters:

s

buf to read the characters to

Returns:

buf on success, null on an error