question on lseek behavior
Conor P. Cahill
cpcahil at virtech.uucp
Fri Jul 6 08:52:39 AEST 1990
In article <1416 at software.software.org> marshall at 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
More information about the Comp.unix.wizards
mailing list