C语言写一行及写换行符的问题
(2010-08-08 09:05:22)
标签:
c换行写文件一行it |
分类: 实验室 |
int fputs( const char *str, FILE
*stream );
将str中的字符串拷贝到stream的当前位置,str字符串最后的null终止字符(如果有的话)并不会被拷贝进去。
至于换行符,msdn介绍fwrite时说了:
将str中的字符串拷贝到stream的当前位置,str字符串最后的null终止字符(如果有的话)并不会被拷贝进去。
至于换行符,msdn介绍fwrite时说了:
size_t fwrite( const void *buffer, size_t size, size_t count, FILE *stream );The fwrite function writes up to count items, of size length each, from buffer to the output stream. The file pointer associated with stream (if there is one) is incremented by the number of bytes actually written. If stream is opened in text mode, each carriage return is replaced with a carriage-return – linefeed pair. The replacement has no effect on the return value.
This function locks the calling thread and is therefore thread-safe. For a non-locking version, see _fwrite_nolock.
如果stream是以文本方式打开的,那么str中的\r会被自动替换为\r\n写入stream。但是str本身的\r并没有被替换为\r\n,因此返回值中\r还是算写了一个字符。

加载中…