如题所述
第1个回答 2010-08-24
很简单,只要得到该文本文件大小为0,即为空文本
WIN32_FIND_DATA fileInfo;
HANDLE hFind;
DWORD fileSize;
const char *fileName = 文件[wen jian]的路径[lu jing]及名字;
hFind = FindFirstFile(fileName ,&fileInfo);
if(hFind != INVALID_HANDLE_VALUE)
fileSize = fileInfo.nFileSizeLow;
FindClose(hFind);
给分。。。
WIN32_FIND_DATA fileInfo;
HANDLE hFind;
DWORD fileSize;
const char *fileName = 文件[wen jian]的路径[lu jing]及名字;
hFind = FindFirstFile(fileName ,&fileInfo);
if(hFind != INVALID_HANDLE_VALUE)
fileSize = fileInfo.nFileSizeLow;
FindClose(hFind);
给分。。。
第2个回答 2010-08-24
stat函数,stat结构体中st_size为文件的大小,可以根据它来判断本回答被提问者采纳
第3个回答 2010-08-24
FILE *fp;
fp= fopen("文件名","r");
printf("filesize is %d\n",filesize(fp));
int filesize(FILE *stream)
{
long curpos, length;
curpos = ftell(stream);
fseek(stream, 0L, SEEK_END);
length = ftell(stream);
fseek(stream, curpos, SEEK_SET);
return length;
}
fp= fopen("文件名","r");
printf("filesize is %d\n",filesize(fp));
int filesize(FILE *stream)
{
long curpos, length;
curpos = ftell(stream);
fseek(stream, 0L, SEEK_END);
length = ftell(stream);
fseek(stream, curpos, SEEK_SET);
return length;
}