C++ Programming/Code/Standard C Library/Functions/fgets
fgets
editSyntax |
#include <cstdio>
char *fgets( char *str, int num, FILE *stream );
|
The function fgets()
reads up to num
- 1 characters from the given file stream and dumps them into str
. The string that fgets()
produces is always null-terminated. fgets()
will stop when it reaches the end of a line, in which case str
will contain that newline character. Otherwise, fgets()
will stop when it reaches num
- 1 characters or encounters the EOF
character. fgets()
returns str
on success, and NULL
on an error.