Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!olivea!mintaka!ogicse!orstcs! From: thurmag@jacobs.cs.orst.edu (Gary Thurman) Newsgroups: comp.lang.c Subject: fseek() help Message-ID: <1991May16.212132.24371@lynx.CS.ORST.EDU> Date: 16 May 91 21:21:32 GMT Sender: @lynx.CS.ORST.EDU Organization: Oregon State University, CS Dept. Lines: 53 Nntp-Posting-Host: jacobs.cs.orst.edu I thought I had the problem solved (after reading out of 3 books to get this far), but the following fseek() function still does not work. The information I wish to remove from the database file is still present. Any more idea's as to what I should try next, would be appreciated. /* remove a name from the list */ void delete() { FILE *fptr; char name[40]; struct addr addr_info; long file_pos; if((fptr=fopen("maillist.dbf","r+b"))==NULL) { fprintf(stderr,"Can't open, name not found.\n"); return; } printf("\n\n\n\n\n\n\t\t\tName your looking for? "); gets(name); while(!feof(fptr)) { file_pos = ftell (fptr); fread(&addr_info,sizeof(struct addr),1,fptr); if(!strcmp(addr_info.name, name)) { printf("\n\n\n\n\n\n\t\t\t\t%s\n", &addr_info.name); printf("\t\t\t\t%s\n", &addr_info.street); printf("\t\t\t\t%s\n", &addr_info.city); printf("\t\t\t\t%s\n", &addr_info.state); printf("\t\t\t\t%s\n", &addr_info.zip); printf("\n\t\tIs this the name you want to remove? (Type 'y' or 'n'): "); while(getche() == 'y') { addr_info.delete='y'; if(fseek(fptr, file_pos, SEEK_SET)); fwrite(&addr_info,(long) sizeof(struct addr),1,fptr); clrscr(); return; } } } fclose(fptr); } -- _**_ "We came...We saw...We kicked some ASH!" /____|-IIIIIIIIIIII Gary Thurman ------ FIREFIGHTER/EMT 2 >| 132 |-----------\ Email: thurmag@jacobs.cs.orst.edu +-(O)--------(O)--+ Corvallis, Oregon