fgets()

#include <stdio.h>

char* fgetc( char* storage, int max_line, FILE* file_pointer );

This function read the next line from the files referenced by file_pointer and stores it at address storage.

The "next line" consists of the next max_line - 1 characters, OR all characters up to and including the next newline character, OR all charactes up to the end of the file. WHICHEVER IS SHORTEST. If at least one character is stored, fgets() adds a terminating null to the end of the line ('\0'). fgets() will store the newline character if read. If no characters are stored or an error occurs, fgets() returns NULL; otherwise, fgets() returns the address storage

See also gets()


Back to Essential C Functions

Log in or register to write something here or to contact authors.