ff_stdio.h
int ff_fputc( int iChar, FF_FILE * pxStream );
将单个字节写入嵌入式 FAT 文件系统中的打开文件。
增加了一个读取/写入位置。
在 int 中传递字符可能不是最佳方式,但 ff_fputc()
原型符合标准和预期的 stdio fputc() 函数原型。
参数:
iChar
|
写入文件的值。 该值在被写入之前
已转换为未签名的字符(8 位)。
|
pxStream
|
指向被写入字符的文件的指针。
该指针与调用
ff_fopen() 返回的指针相同,最初用于打开文件。
|
返回:
如果成功,将返回写入文件的字节。 如果返回有任何
其他值,则未将字节写入文件,并且任务
errno 将设置为指示原因。 任务
可以使用 stdioGET_ERRNO() API 函数
获取其 errno 值。
用法示例:
void vSampleFunction( char *pcFileName, int32_t lNumberToWrite )
{
FF_FILE *pxFile;
const int iCharToWrite = 'A';
int iCharWritten;
int32_t lBytesWritten;
pxFile = ff_fopen( pcFileName, "w" );
for( lBytesWritten = 0; lBytesWritten < lNumberToWrite; lBytesWritten++ )
{
iCharWritten = ff_fputc( iCharToWrite, pxFile );
if( iCharWritten != iCharToWrite )
{
break;
}
}
ff_fclose( pxFile );
}
Example use of the ff_fputc() API function
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.