在追加模式下打开文件:使用 open() API [英] Opening file in Append mode : using open() API

查看:38
本文介绍了在追加模式下打开文件:使用 open() API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 open() api 调用以追加模式打开文件,但是以下代码不起作用!它没有向文件写入任何内容!这是我的代码:

i am trying to open a file in append mode using open() api call , however following code is not working ! Its not writing anything to file! here is my code :

推荐答案

O_APPEND 本身不是一种模式;这是一面旗帜.由于 O_RDONLY 的值为 0,这就像您试图以只读方式打开文件但进行追加,这是无稽之谈.使用 O_WRONLY|O_APPENDO_RDWR|O_APPEND.

O_APPEND is not a mode by itself; it's a flag. Since the value of O_RDONLY is 0, it's like you're trying to open the file read-only but for append, which is nonsense. Use O_WRONLY|O_APPEND or O_RDWR|O_APPEND.

这篇关于在追加模式下打开文件:使用 open() API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆