它创建包含所需结果的临时文件。但它没有删除以前的文件" records.txt"而不是重命名temp.txt。即时通讯使用dev c ++。
void delete()
{
FILE *fp, *ft;
int no;
char ch;
student stud;
fp = fopen("Records.txt","r");
printf("\nEnter student's RollNo to delete:");
scanf("%d",&no);
ft = fopen("temp.txt","w+");
while (!feof(fp))
{
fscanf(fp, "\n%d\t%s\t", &stud.roll_no, stud.name);
if (stud.roll_no != no)
{
fprintf(ft, "\n\t%d \t%s", stud.roll_no, stud.name);
}
}
fclose(fp);
fclose(ft);
remove("Records.txt");
rename("temp.txt","Records.txt");
}