Your write routine has the problem. You need to fseek every write.
Your original read routine works also with this modification on the write routine.Code:printf("\nEnter no. "); scanf("%d",&x); printf("\nEnter name: "); scanf("%s",&st); strcpy(my_data[x-1].name,st); printf("\nOwes? "); scanf("%f",&owe); my_data[x-1].owes=owe; printf("\nWRITER"); /* randomly move pointer to the right record position to write */ fseek(file_pointer, (x-1) * sizeof(struct entry), SEEK_SET ); fwrite(&my_data[x-1],sizeof(struct entry),1,file_pointer);




Reply With Quote