Quote:
Originally posted by alaios
Where have u learned all these?
|
In books on C-programming for UNIX/Linux.[/quote]
Those read(2) and open(2) functions are the actual functions that talk to the kernel (low-level). fgets(3), fprintf(3) and friends use those low-level functions.
When reading line-by-line, read(2) is harder to use than fgets(). fgets(3) and other stdio-functions try to optimize things through buffering by line.
But when you want to read an entire file at once, you can get to do the buffering yourself by using read(2) directly. So you can buffer-by-file, which is optimal.
You can create a buffer dynamically, exactly as big as you need for the file. But you'll need to know the file size, which you can do with fstat(2).
Quote:
Where have u learned about #include <fcntl.h> library
|
I read that in: man 2 open
You're welcome.