本文介绍了C fopen模式参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么C中的fopen的模式"参数由字符串给出? (以我的思维方式)将其作为位掩码或类似符号会更有意义.字符串所需的开销是低效且不必要的.

Why is the 'mode' paramter for fopen in C given by a string? It would make more sense (in my way of thinking) for it to be a bitmask or the likes. The overhead a string necessitates is inefficient and unnecessary.

推荐答案

在脚注中:

根据C99基本原理,委员会认为实现可以选择使用mode而不是标志:

According to the C99 Rationale, the committee thinks an implementation may choose to use mode other than the flags:

file1 = fopen(file1name, "wb,reclen=80");

可能是在提供面向记录的二进制文件并允许程序员指定记录长度的系统上的合理扩展.

might be a reasonable extension on a system that provides record-oriented binary files and allows a programmer to specify record length.

GNU libc的扩展允许mode包含ccs=STRING,请参见 glibc手册

GNU libc has an extension that allows mode contains ccs=STRING, see glibc manual

这篇关于C fopen模式参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 17:41
查看更多