c语言中,成功调用fprintf fscanf函数后有什么返回值吗

2024-11-27 02:43:39
推荐回答(1个)
回答1:

当然有。楼主可看MSDN有详细描述,

fscanf, fwscanf
Read formatted data from a stream.
int fscanf( FILE *stream, const char *format [, argument ]... );
int fwscanf( FILE *stream, const wchar_t *format [, argument ]... );

Return Value // 也就是正常会返回从文件成功写入的变量个数,否则返回EOF
Each of these functions returns the number of fields successfully converted and assigned; the return value does not include fields that were read but not assigned. A return value of 0 indicates that no fields were assigned. If an error occurs, or if the end of the file stream is reached before the first conversion, the return value isEOFfor fscanf orWEOFforfwscanf.

fprintf, fwprintf
Print formatted data to a stream.
intfprintf(FILE*stream,constchar*format[,argument]...);
intfwprintf(FILE*stream,constwchar_t*format[,argument]...);

Return Value // 也就是正常会返回写入文件的字节数,否则返回负数
fprintfreturns the number of bytes written.fwprintfreturns the number of wide characters written. Each of these functions returns a negative value instead when an output error occurs.