Last modified on 20 July 2010, at 19:05

C++ Programming/Code/Standard C Library/Functions/fgets

fgetsEdit

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