1) what is faster to access a file (if any is better), the functions of C (fopen, fprintf, fseek, etc) or calls to UNIX (open, write, lseek, etc. )?
open
opens a file and gives you direct access to it. The functions of the unix API access the file through the descriptor provided by open
.
fopen
opens a file, assigns it a buffer and gives you access to that buffer. The changes are not instantaneously reflected but stored in the intermediate buffer until they are permanently transferred to the file. The rest of the f*
functions work on the mentioned buffer. Needless to say, to open the file, fopen
has to end up calling the linux API (remember that unix was the germ, currently almost everything is linux ).
So a boat could soon say that open
should provide better response times (in the end fopen
implies a call to open
), but that secondary buffer can get to work wonders so the The conclusion you can reach is that depending on what you are doing, there will be a better mechanism than another.
On the other hand, the family f*
are of higher level than the functions of the Linux API, which will allow you to simplify many operations related to the treatment of files.
It is not a conclusive answer but it is that none is going to be it.
2) How can you read formatted text using system calls (as is done with fscanf, for example to read whole numbers)?
As I said, the linux API is low level and does not implement many existing utilities in high-level functions ... you have to currarte the conversion mechanisms.