thurmag@jacobs.cs.orst.edu (Gary Thurman) (05/17/91)
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