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


[FreeRTOS Embedded File System API]

int f_putc( int iChar, F_FILE *pxFileHandle );

Writes a single character into an open FAT file. The data is written at the current file read/write position, and the current file read/write position is incremented by one.

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


iChar   The character to be written to the file.

The int data type is not appropriate to hold a character but is used to comply with the expected standard file system API.

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

The character being written   The character was successfully written to the file.

Any other value   The character was not successfully written to the file.

See also


Example usage:

void vSampleFunction( char *pcFileName, long lNumberToWrite )
F_FILE *pxFile;
const int iCharToWrite = 'A';
int iCharWritten;
long lBytesWritten;

    /* Open the file specified by the pcFileName parameter for writing. */
    pxFile = f_open( pcFileName, "w" );

    /* Write 'A' to the file the number of times specified by the
    lNumberToWrite parameter. */
    for( lBytesWritten = 0; lBytesWritten < lNumberToWrite; lBytesWritten++ )
        /* Write the byte. */
        iCharWritten = f_putc( iCharToWrite, pxFile );

        /* Was the character written to the file successfully? */
        if( iCharWritten != iCharToWrite )
            /* The byte could not be written to the file. */

    /* Finished with the file. */
    f_close( pxFile );
Example use of the f_putc() 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.