f_gets

The f_gets reads a string from the file.

TCHAR* f_gets (
  TCHAR* buff, /* [OUT] Read buffer */
  int len,     /* [IN] Size of the read buffer */
  FIL* fp      /* [IN] File object */
);

Parameters

buff
Pointer to read buffer to store the read string.
len
Size of the read buffer in unit of character.
fp
Pointer to the open file object structure.

Return Values

When the function succeeded, buff will be returuned.

Description

The f_gets() function is a wrapper function of f_read() function. The read operation continues until a '\n' is stored, reached end of the file or the buffer is filled with len - 1 characters. The read string is terminated with a '\0'. When no character to read or any error occured during read operation, it returns a null pointer. The status of eof and error can be examined with f_eof() and f_error() macros.

When the FatFs is configured to Unicode API (_LFN_UNICODE == 1), the file is read in assumption of UTF-8 encoding and stored it to the buffer in UCS-2. If not the case, the file will be read in one byte per character without any code conversion.

QuickInfo

Available when _USE_STRFUNC is 1 or 2. When it is set to 2, '\r's contained in the file are stripped out.

See Also

f_open, f_read, f_putc, f_puts, f_printf, f_close, FIL

Return