i'm trying to delete an account in my file but the problem is that i can reach my position depending on my index but i cann'ty write in this record
Code:
void account_delete(char *filename)
{
int pos;
account temp;
FILE *file=fopen(filename,"rb+");
if(file!=NULL)
{
printf("enter the index to modify");
scanf("%d",&pos);
fseek(file, (pos -1 ) *sizeof(account), SEEK_SET );
fread(&temp, sizeof(account), 1,file);
printf("%s\n",temp.name);
strcpy(temp.name,"");strcpy(temp.password,"");strcpy(temp.previleges,"");
printf("%s\n",temp.name);
fwrite(&temp,sizeof(account),1,file);
}
viewall(filename);
fclose(file);
}
please some suggestions if possible