Real time embedded FreeRTOS RSS feed 
Homepage FreeRTOS+ Products FreeRTOS Labs Support Forum Contact / Enquiries


[FreeRTOS Embedded File System API]

int f_getc( F_FILE *pxFileHandle );

Reads a single byte from the current read/write position of an open FAT file. The current file position is incremented by one.

A file can only be read if it was opened with one of the following option strings: "r", "r+", "w+" or "a+" (see f_open()).


pxFileHandle   The handle of the file from which a character is being read. The handle is returned by the call to f_open() used to originally open the file.

-1   A character was not read from the file.

Any other value   The character that was read from the file.

See also


Example usage:

void vSampleFunction( char *pcFileName, char *pcBuffer, long lBufferSize )
F_FILE *pxFile;
long lBytesRead;
int iReturnedByte;

    /* Read the file specified by the pcFileName parameter. */
    pxFile = f_open( pcFileName, "r" );

    /* Read the number of bytes specified by the lBufferSize parameter. */
    for( lBytesRead = 0; lBytesRead < lBufferSize; lBytesRead++ )
        iReturnedByte = f_getc( pxFile );

        if( iReturnedByte == -1 )
            /* A byte could not be read. */
            /* Write the byte into the buffer. */
            pcBuffer[ lBytesRead ] = ( char ) iReturnedByte;

    /* Finished with the file. */
    f_close( pxFile );
Example use of the f_getc() API function

[ Back to the top ]    [ About FreeRTOS ]    [ Privacy ]    [ FreeRTOS+ Sitemap ]    [ Main FreeRTOS Sitemap ]    [ ]

Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.