Namespaces
Variants
Views
Actions

fgets

From cppreference.com
< c‎ | io
Revision as of 15:22, 1 July 2013 by P12bot (Talk | contribs)

Defined in header <stdio.h>
char *fgets( char          *str, int count, FILE          *stream );
(until C99)
char *fgets( char *restrict str, int count, FILE *restrict stream );
(since C99)

Reads at most count - 1 characters from the given file stream and stores them in str. 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.

Parameters

str - string to read the characters to
count - the length of str
stream - file stream to read the data from

Return value

str on success, NULL on an error

See also

reads formatted input from stdin, a file stream or a buffer
(function) [edit]
(until C11)
reads a character string from stdin
(function) [edit]
writes a character string to a file stream
(function) [edit]