bool isFileEmpty(QString filename)
{
int len = 0;
FILE* fp = fopen(filename.toStdString().c_str(), "rb");
if (NULL == fp)
return len;
fseek(fp, 0, SEEK_END); //先将指针偏移到文件尾
len = ftell(fp);
fseek(fp, 0, SEEK_SET); //再将指针偏移到文件头
fclose(fp);
if(len > 0)
return false;
return true;
}
C语言判断文件内容是否为空
![](https://img-home.csdnimg.cn/images/20240711042549.png)