关于文件输出状态的问题
最近在学文件时遇到很多疑惑,文件读取后的状态是什么样的,空的吗?我做了个程序,想要删除文件中的一组数,但是运行后文件就空了,这是不是说文件读出后是空的?编的程序代码如下:
程序代码:#include<stdio.h>
#include<stdlib.h>
struct teacher
{
int num;
char name[20];
char sex;
float wage;
};
void main()
{
FILE *fq;
struct teacher f;
int n;
if((fq=fopen("e:\\1.txt","wt+"))==NULL)
{
printf("can not open the file");
exit(1);
}
printf("please input the one you want");
scanf("%d",&n);
while(fread(&f,sizeof(struct teacher),1,fq)==1)
{if(n==f.num) continue;
fwrite(&f,sizeof(struct teacher),1,fq);}
fclose(fq);
}









