The new-line character (\n) that ends the line is replaced by the function with an ASCII null character (\0). When stdin is opened in record mode, gets treats the end of a record the same as a new-line character and, therefore, reads up to and including a new-line character or to the end of the record.