The fgets() function is used for reading a string from the specified file. Here is its syntax:
char *fgets(char *string, int length, FILE *file_pointer)
This function has the following features:
- string: This represents the character array to which the data that is read from the file will be assigned.
- length: This represents the maximum number of characters that can be read from the file. The length-1 number of characters will be read from the file. The reading of data from the file will stop either at length-1 location or at the new line character, \n, whichever comes first.
- file_pointer: This represents the file pointer that is pointing at the file.