Table of Contents        Previous topic       Next topic       

C COMPILER LIBRARY FUNCTIONS->Detailed Descriptions->fgets()


#include <stdio.h>

int fgets(char* string, int n, FILE* stream);    Read characters from stream


stringPointer to char array pointer to receive characters
nNumber of characters to read
streamPointer to file structure


This function reads at most the next n-1 characters from stream into the array pointed to by string.  Input stops if a newline character is encountered.  The newline character is included in the array and the array is terminated by '\0'.  stdin is the only input stream supported.

Return Value

The function returns string or NULL if an error occurred.