The fprintf function writes formatted string to the file.
int fprintf ( FIL* FileObject, /* File object */ const char* 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 will be returned.
The fprintf() is a wrapper function of fputc() and fputs(). The format control directive is a sub-set of standard library. It supports c s d u X for the data type, l for the precision and 0 for the flags.
This function is available when read-write configuration and _USE_STRFUNC is 1 or 2.
fprintf(&fil, "%6d", -200); // " -200" fprintf(&fil, "%02u", 5); // "05" fprintf(&fil, "%ld", 12345678L); // "12345678" fprintf(&fil, "%08lX", 1194684UL); // "00123ABC" fprintf(&fil, "%s", "String"); // "String" fprintf(&fil, "%c", 'a'); // "a"