Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tdatirv!sarima From: sarima@tdatirv.UUCP (Stanley Friesen) Newsgroups: comp.lang.c Subject: Re: file descriptor vs file handle Message-ID: <154@tdatirv.UUCP> Date: 26 Feb 91 16:03:11 GMT References: <90361.145855COS99291@ufrj.bitnet> <27C9CB35.5F7@wilbur.coyote.trw.com> Reply-To: sarima@tdatirv.UUCP (Stanley Friesen) Organization: Teradata Corp., Irvine Lines: 23 In article <27C9CB35.5F7@wilbur.coyote.trw.com> 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? A file handle (as you call it) is a small integer used by the operating system (MS-DOS?) to access the file state, and allow it to perform I/O on your behalf. What you call a file descriptor is a pointer to an application level structure containing state information used by the standard I/O library. (And *only* by the standard I/O library). Among other things, this structure contains the file handle for the file. Note that the terminology your documentation uses is *not* universal. [I have only seen this terminology in the Lattice C compiler docs for MS-DOS, though MSC may also use it]. Be aware that in most UNIX docs the term file descriptor usually refers to what you call a file handle, and your 'file descriptor' is usually called a 'FILE pointer'. -- --------------- uunet!tdatirv!sarima (Stanley Friesen)