.FScanf()

back to FEHSD

Description

This function is used to read from a file on the SD card. Every call to this function will read a single line of the file. So, this function needs to be called multiple times in order to read multiple lines.

Syntax

.FScanf(FEHFile* fptr, const char* format, ...);

Parameters

fptr: Pointer to FEHFile opened for reading
str: List of format specifiers of data to be read in
...: 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 successfully read-in pieces of data or EOF if the function failed

Examples

#include <FEHSD.h>

int main(void)
{
    int num;
    // Open new file for writing
    FEHFile *fptr = SD.FOpen(“Test.txt”,”r”);
    // Read data from the opened file
    SD.FScanf(fptr, “%d”, &num);
    // Close file
    SD.FClose(fptr); 
}