Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why fputs and fprintf reverse stream order

Tags:

c

printf

fputs

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

like image 811
qianchenglong Avatar asked Jan 15 '15 03:01

qianchenglong


1 Answers

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

like image 193
paxdiablo Avatar answered Nov 08 '22 07:11

paxdiablo