Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Homepage FreeRTOS+ Products FreeRTOS Labs Integration Services Contact / Enquiries

f_putc()

[FreeRTOS Embedded File System API]

header_file.h
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()).

Parameters:

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.

Returns:
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

f_write().

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. */
            break;
        }
    }

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


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


Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.