The fgets() function is used for reading a string from the specified source, where the source can be any file, keyboard, or another input device. Here is its syntax:
char *fgets(char *str, int numb, FILE *src);
The numb number of bytes are read from the specified source src and assigned to the string pointed to by str. The function either reads numb-1 bytes, or until a newline (\n) is reached, or an end of file is encountered, whichever happens first.
The function also appends the null character (\0) to the string that is read to terminate the string. If executed successfully, the function returns a pointer to str and returns NULL if an error occurs.