why fputs and fprintf reverse stream order

霸气de小男生 提交于 2019-12-08 17:13:59

问题


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);

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


回答1:


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

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.

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..



来源:https://stackoverflow.com/questions/27956340/why-fputs-and-fprintf-reverse-stream-order

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!