Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!decwrl!mcnc!ecsgate!ecsvax!uncw!session From: session@uncw.UUCP (Zack C. Sessions) Newsgroups: comp.lang.c Subject: Re: file descriptor vs file handle Message-ID: <1021@uncw.UUCP> Date: 26 Feb 91 18:33:09 GMT References: <90361.145855COS99291@ufrj.bitnet> <27C9CB35.5F7@wilbur.coyote.trw.com> Organization: Univ. of North Carolina at Wilmington Lines: 26 cwong@charlie.coyote.trw.com (Chun Wong) writes: >Can someone distinguish the differences between a file descriptor and >a file handle? I know that creat returns a file handle whereas fopen >returns a file descriptor. What's the difference? Are they interchangeable? >-C. Wong A file handle as you call it is also referred to as a path. It is typically an int variable and is used by creat and open and read and write and close. (plus others). A File Descriptor is a special structure which is specific for your system and defined in your stdio.h defs file. It usually contains a file handle (path) as part of it's data structure. Files which you access with File Descriptors use the fopen, printf and scanf constructs, fread, fwrite, and fclose (plus others). The distinct difference between the two is that files accessed through a File Descriptor are accessed in a method call "buffered IO". This can sometimes greatly increase the performance of your program at runtime. Also, the "raw IO" calls are not always implemented the same on all machines or compilers and sometimes not implemented at all. Use of only buffered IO can usually guarantee portability if that's an issue. Zack Sessions ...!ecsvax!uncw!session