Utility Functions and C Language Reference > C Language Reference > Alphabetical List of Functions > fgets

fgets

Example: fgets Input-Output Functions

Reads a string from a file.

char *fgets( char *string, int maxchar, FILE *file_pointer);

string The string to retrieve.
maxchar The maximum number of characters to retrieve.
file_pointer A pointer to a file.

Return Values

Upon success, it returns the read string. If the End Of File is reached or if a reading error occurred, it returns a null pointer.