I have to compute a file, reading sequentially one character at time. Is it
more convenient (in speed terms) use getc() or copy first the whole file in
a memory buffer and operate with it?
Make things so simple as possible! When you have to read a stream char
by char - do so! The system your implementation is running under uses
itself a buffer to handle the I/O primitives the most performant way.
Your implementation uses internally a buffer too, so why does you mean
you have to create yourself another layer of buffers? You makes things
only more complicate than necessary.
O.k., you may play around with setvbuf() but in most cases that will
do nothing for performance anyway.
Use getc() instead of fgetc() and hope that your implementation will
realise getc as macro, so you saves the overhead of a call when the
implementation internal buffer is not empty.
--
Tschau/Bye
Herbert Rosenau
http://www.pc-rosenau.de eComStation Reseller in Germany
eCS 1.1 german is in beta testing