Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!yale!cmcl2!uupsi!sunic!news.funet.fi!hydra!cc.helsinki.fi!wirzenius From: wirzenius@cc.helsinki.fi (Lars Wirzenius) Newsgroups: comp.lang.c Subject: Re: file descriptor vs file handle Message-ID: <1991Mar1.134316.5301@cc.helsinki.fi> Date: 1 Mar 91 13:43:16 GMT References: <90361.145855COS99291@ufrj.bitnet> <27C9CB35.5F7@wilbur.coyote.trw.com> <1991Feb27.192725.26421@pinet.aip.org> Organization: University of Helsinki Lines: 21 In article <1991Feb27.192725.26421@pinet.aip.org>, reg@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@cc.helsinki.fi