The f_printf function writes formatted string to the file.
int f_printf ( FIL* FileObject, /* File object */ const TCHAR* Foramt, /* Format stirng */ ... );
When the function succeeded, number of characters written is returned. When the function failed due to disk full or any error, an EOF (-1) will be returned.
The f_printf() is a wrapper function of f_putc() and f_puts(). The format control directive is a sub-set of standard library shown as follos:
Available when _FS_READONLY == 0 and _USE_STRFUNC is 1 or 2. When it is set to 2, '\n's contained in the output are converted to "\r\n".
When the FatFs is configured to Unicode API (_LFN_UNICODE == 1), the generated UCS-2 characters are written to the file in UTF-8 encoding. If not the case, the byte characters will be written directly.
    f_printf(&fil, "%d", 1234);            /* "1234" */
    f_printf(&fil, "%6d,%3d%%", -200, 5);  /* "  -200,  5%" */
    f_printf(&fil, "%-6u", 100);           /* "100   " */
    f_printf(&fil, "%ld", 12345678L);      /* "12345678" */
    f_printf(&fil, "%04x", 0xA3);          /* "00a3" */
    f_printf(&fil, "%08LX", 0x123ABC);     /* "00123ABC" */
    f_printf(&fil, "%016b", 0x550F);       /* "0101010100001111" */
    f_printf(&fil, "%s", "String");        /* "String" */
    f_printf(&fil, "%-4s", "abc");         /* "abc " */
    f_printf(&fil, "%4s", "abc");          /* " abc" */
    f_printf(&fil, "%c", 'a');             /* "a" */
    f_printf(&fil, "%f", 10.0);            /* f_printf lacks floating point support */