the problem is that i want to delete an account using this code any help?
Quote:
Originally Posted by
overlord21
Code:
void account_delete(char *filename)
{
int count=0,i=0;
char NAME[20];
account t[20];
FILE *file=fopen(filename,"wb");
if(file!=NULL)
{
while(fread(&t[i],sizeof (account),1,file)==1)
{
i++;
count++;
}
}
printf("give the name of account");
scanf("%s",&NAME);
for(int g=0;g<count;g++)
{if(strcmp(t[g].name,NAME)==0)
{ for(int h=g;h<count;h++)
{
t[h]=t[h+1];
}
}
}
count--;
print_file(t,count);
fclose(file);
this ffunction has a role of deleting the found account but it has two problems: to delete from the string t[] and to overwrite/write in the file
the problem is that i want to delete an account using this code any help?