The fgets() function returns a line from an open file.
The fgets() function will stop returning a new line when it reaches the specified length (length - 1), encounters a newline character, or reaches the end of file (EOF), whichever comes first.
This function returns FALSE on failure.
fgets(file,length)
parameter | describe |
---|---|
file | Required. Specifies the file to be read. |
length | Optional. Specifies the number of bytes to read. The default is 1024 bytes. |
The above code will output:
Hello, this is a test file.
The above code will output:
Hello, this is a test file. There are three lines here. This is the last line.