我正在尝试将使用无缓冲 I/O ( open()
, read()
,write()
函数) 编写的项目迁移到缓冲 I/O ( fopen()
, fread()
,fwrite()
函数)。
我遇到了一些虚拟问题: Adapting zoo of open()
flags to fopen()
set r,r+,w,w+,a,a+
.
这似乎很无聊且容易出错。还有其他方法可以做到这一点吗?
我正在尝试将使用无缓冲 I/O ( open()
, read()
,write()
函数) 编写的项目迁移到缓冲 I/O ( fopen()
, fread()
,fwrite()
函数)。
我遇到了一些虚拟问题: Adapting zoo of open()
flags to fopen()
set r,r+,w,w+,a,a+
.
这似乎很无聊且容易出错。还有其他方法可以做到这一点吗?
I would use grep | sort | uniq
to find all the cases in the source
code, then work out their translations, and write a simple Python script
to replace.
您可以编写一些带有参数(称为 等)的 C 宏,这些参数open()
扩展close()
为正确的调用。但是,它也容易出错。因此,我宁愿依靠一些强大的编辑器(例如,vim)和正则表达式来改变所有的出现。