Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!uunet!virtech!cpcahil From: cpcahil@virtech.uucp (Conor P. Cahill) Newsgroups: comp.unix.wizards Subject: Re: question on lseek behavior Keywords: weirdo Unix system call behavior Message-ID: <1990Jul05.225239.13405@virtech.uucp> Date: 5 Jul 90 22:52:39 GMT References: <1416@software.software.org> Reply-To: cpcahil@virtech.UUCP (Conor P. Cahill) Distribution: usa Organization: Virtual Technologies Inc., Sterling VA Lines: 21 In article <1416@software.software.org> marshall@software.org (Eric Marshall) writes: > > I was trying to use lseek to rewind to the beginning >of input (a file), but I ran into difficulties. When I run >the program below, it outputs the file missing the first 3 characters, >as if the lseek didn't do anything, then it outputs the entire >file. Could someone please explain why this occurs. I eventually >found the rewind(3S) call, and it works fine. I am running >on SunOS 4.1. You cannot mix FILE POINTER calls with file descriptor calls (or in other words, stdio calls with system calls). if you use getc, fgets, gets, scanf, etc you must use fseek to seek in a file. if you use read you must use lseek. -- Conor P. Cahill (703)430-9247 Virtual Technologies, Inc., uunet!virtech!cpcahil 46030 Manekin Plaza, Suite 160 Sterling, VA 22170