file descriptor vs file handle

Lars Wirzenius wirzenius at cc.helsinki.fi
Sat Mar 2 00:43:16 AEST 1991


In article <1991Feb27.192725.26421 at pinet.aip.org>, reg at pinet.aip.org (Dr. Richard Glass) writes:
> I think what you want to know is what the difference between the IO
> routines read, write, creat versus fgets, fopen etc.  The first set of
> routines are also known as Level I IO and "raw data movers".  They
> perform NO translation of data andd read/write at the byte level. 
>[...]
> To insure portability, level 2 should be used.  One can perform
> untranslated IO using the routines fread and fwrite

The difference between 'level 1' (open, read, write, close) and 'level
2' (fopen, fgets, fputs, fclose, etc) is not that 'level 1' doesn't do
translation and 'level 2' does, but that 'level 2' gives buffering and
makes it easier to operate on 'meaningful' chunks of data, e.g. chars
and lines. Remember, in Unix there is no translation needed, unlike most
other systems.

For portability and conformance to the standard, 'level 2' should be
used. For efficiency, it depends.

-- 
Lars Wirzenius    wirzenius at cc.helsinki.fi



More information about the Comp.lang.c mailing list