Reputation: 10131
Actually this is not particular to C, but assume using C first, if I have a program that read from stdin
, and a program read from a file using fopen
, how to compare their efficiency in processing file?
What would be the overheads on both cases?
Upvotes: 0
Views: 123
Reputation: 215577
If you mean to compare reading from a file that's received as stdin
(e.g. ./prog < file
) versus opened within the program via fopen
, there should be no difference in efficiency whatsoever.
If you mean to compare reading from a pipe or terminal or other non-regular-file received as stdin
versus opening regular file with fopen
, you're comparing apples and oranges and I don't think the question makes sense without further details.
Upvotes: 2