Xref: utzoo comp.sys.hp:3223 comp.lang.c:23025 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!tut.cis.ohio-state.edu!bloom-beacon!eru!luth!sunic!his!jonas From: jonas@his.UUCP (Jonas Mellin) Newsgroups: comp.sys.hp,comp.lang.c Subject: fseek doesn't work properly Keywords: fseek, C Message-ID: <496@his.UUCP> Date: 19 Oct 89 18:19:23 GMT Reply-To: jonas@his.UUCP (Jonas Mellin) Followup-To: comp.sys.hp Organization: Hogskolan i Skovde, Skovde, Sweden Lines: 75 We have a couple of HP9000/8XX machines with HPUX 3.1. The problem: fseek moves the filepointer to beginning of the file regardless of the parameters Solution: if setbuf is used to either: 1) set no buffer or 2) set user declared buffer on the file; fseek will work properly in forward searches, but it will not work in relative searches nor in searches from the end of the file. Question: Does anyone else have this problem? Here is a testprogram which works if the comments are removed from the line containing the call to 'setbuf'. The program creates the file 'test' and then is then meant to update the file. #include #define N struct dummy_struct { int a; char b[N]; } a; void main() { FILE *fp; int i; char buf[BUFSIZ]; fp=fopen("test","w"); for (a.a='A'; a.a<'z'; a.a++) { for (i=0; i