back to FEHSD
Description
This function is used to write to a file. In order to ensure the file is written to successfully, FClose
must be called.
Syntax
.FPrintf(FEHFile* fptr, const char* str, ...);
Parameters
fptr
: Pointer to FEHFile
opened for writing
str
: Formatted string to print
...
: Additional variables to be inserted into the string in run-time
Supported Format Specifiers
Format modifiers such as %.2f are not supported.
Specifier | Description |
---|---|
S,s | Strings |
C,c | Character |
B,b | Binary |
D,d | Integer |
F,f | Float |
Returns
An int containing the number of character encoding units written to the file or a EOF if the function failed.
Examples
#include <FEHSD.h> int main(void) { int num = 13; //Open new file for writing FEHFile *fptr = SD.FOpen(“Test.txt”,”w”); // Write data to the opened file SD.FPrintf(fptr, “This is a test. My favorite number is %d”, num); //Close file SD.FClose(fptr); }