fopen打开模式

  • r 只读
  • w 只写,清空原有内容,文件不存在会创建
  • a 追加只写,
  • w+ 读写, 清空原有内容,文件不存在会创建
  • r+ 读写, 保留原有内容
  • a+ 追加读写,(和r+不同的地方,fseek only sets the read pointer,即只能改变读指针,写都是从文件尾追加)

That's because in a mode, writing to the FILE* always appends to the end. fseek only sets the read pointer in this mode.
Opening a file with append mode ('a' as the first character in the mode argument) causes all subsequent writes to the file to be forced to the then current end-of-file, regardless of intervening calls to the fseek function.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,504评论 0 13
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,723评论 0 3
  • NAME dnsmasq - A lightweight DHCP and caching DNS server....
    ximitc阅读 2,929评论 0 0
  • 今天吃青蛙:①公卫年终检查 ②早起运动5公里 ③视频0913(20:00) ④马甲线打卡(21:00) ⑤早睡洗护...
    七岳一株花阅读 79评论 0 1
  • 对不起,亲爱的自己,又一次不小心把你伤很深,泪如雨下,心如刀割,你受苦了。 总有一些人...
    浅笑嫣然兮阅读 359评论 1 0