open, fopen ?
one can use fopen to write/read binary data to/from a file.
The same can also be achieved by using open.
What exactly are the differences?
As far as I know fopen is standard C and platform independent, right? It also its a buffered I/O.
open on the other hand is declared in different headers for different platforms and its low level (unbuffered) I/O. And therefor should be faster?
Any additional comments or corrections are welcome.
> As far as I know fopen is standard C and platform independent, right?
> It also its a buffered I/O.
By default, yes.
See also setvbuf()
> open on the other hand is declared in different headers for different platforms
And the parameters sometimes vary as well.
> And therefor should be faster?
Probably - but the difference between the two is seldom exciting enough to sacrifice portability.
Using low-level I/O can be slower if you use it incorrectly. Calls to read()/write() are much slower than calls to fread()/fwrite()/fprintf()/etc. (which is the purpose for the buffer in the first place). If you're reading/writing data in large chunks, the low-level I/O is usually faster, but for reading/writing data in smaller bits the stdio routines are faster.