fgets [C++ Reference]
Keywords: c,io,fgets
Date: 2008-10-14T15:42:01-0700

[[fgets]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- fr
- it
- jp
- pl
- ru
- tr

## fgets

Syntax:

        #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.

Related Topics: fputs, fscanf, gets, scanf

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •