Namespaces
Variants
Views
Actions

fgets

From cppreference.com
< c‎ | io
Revision as of 12:30, 10 April 2013 by P12 (Talk | contribs)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <stdio.h>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td >
char *fgets( char          *str, int count, FILE          *stream );
</td>

<td class="t-dcl-nopad"> </td> <td > (until C99) </td> </tr> <tr class="t-dcl ">

<td >
char *fgets( char *restrict str, int count, FILE *restrict stream );
</td>

<td class="t-dcl-nopad"> </td> <td > (since C99) </td> </tr> Template:ddcl list end

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

Template:c/io/dcl list fscanfTemplate:c/io/dcl list getsTemplate:c/io/dcl list fputs