fopen二进制方式和文本方式打开的区别

fopen是一个库函数。

不是系统调用,系统调用是没有什么b或者有b一说的。

 

库函数严格意义上来说,就要分平台实现了,虽然现在有各种各样的标准,比如POSIX, ANSIC等等,但是还是要有这种库函数分平台的意识。

就fopen这个函数就在不同的平台就有不同的实现

win平台:

我基本没有怎么用过,搜了下网上这篇文章:

https://blog.csdn.net/u012372584/article/details/77836168

整体上就是对于回车换行在读写的时候会有不同的操作,其它的不得而知。

 

linux平台:

有没有b都是一样的,没有文本方式二进制方式一说。

 The mode string can also include the letter 'b' either as a last
       character or as a character between the characters in any of the two-
       character strings described above.  This is strictly for
       compatibility with C89 and has no effect; the 'b' is ignored on all
       POSIX conforming systems, including Linux.  (Other systems may treat
       text files and binary files differently, and adding the 'b' may be a
       good idea if you do I/O to a binary file and expect that your program
       may be ported to non-UNIX environments.)

这个是fopen在linux上面官方文档的说明。

 

 

POSIX:

对fopen使用b的介绍为:

 

The character 'b' shall have no effect, but is allowed for ISO C
       standard conformance.  Opening a file with read mode (r as the first
       character in the mode argument) shall fail if the file does not exist
       or cannot be read.

也是没有什么用,但是可以带。

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值