为什么 fputs 和 fprintf 反向流顺序 [英] why fputs and fprintf reverse stream order

查看:73
本文介绍了为什么 fputs 和 fprintf 反向流顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不明白为什么 fputs 和 fprintf 逆流顺序.

I don't get it why fputs and fprintf reverse stream order.

int fputs (const char * str, FILE * stream);
int fprintf (FILE * stream, const char * format, ...);
ssize_t write(int fd, const void *buf, size_t count);

我知道 fprintf 把流放在前面以支持可变参数,但是为什么 fputs 系列不保持一致性???

I known fprintf put stream in forward to support variable arguments,But why fputs series don't keep consistency ???

推荐答案

因为这些东西是几十年前写的,所以通常只是历史学家感兴趣的问题 :-)

Because these things were written many decades ago, it's generally only be a question of interest for historians :-)

可能只是一个设计决定(或缺乏决定)导致他们变成这样,并且由于 ISO 重视向后兼容性,他们从未改变过它.

It was probably just a design decision (or lack of decision) that caused them to be this way and, since ISO value backward compatibility, they've never changed it.

可能puts 是先写的,到了写 fputs 的时候,开发人员只是简单地剪切了它,将新参数添加到末尾.即使 printf/fprintf 存在相同的情况,由于需要将变量参数列表放在最后,这也是不可能的.

It may be that puts was written first and, when it came time to write fputs, the developer simply cut'n'pasted it, tacking the new parameter onto the end. Even if the same situation existed for printf/fprintf, that wouldn't have been possible due to the need for the variable argument list to be at the end.

但是,抛开假设,既然我们心爱的丹尼斯走了,我们可能永远不会知道实际原因..

But, supposition aside, now that our beloved Dennis is gone, we may never know the actual reasons..

这篇关于为什么 fputs 和 fprintf 反向流顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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