可以通过 fseek() 函数获取
#include
int main ()
{
FILE * pFile=NULL;
long size;
pFile = fopen ("myfile.txt","rb");
if (pFile==NULL)
perror ("Error opening file");
else
{
fseek (pFile, 0, SEEK_END);
size=ftell (pFile);
fclose (pFile);
pFile=NULL;
printf ("Size of myfile.txt is: %ld bytes.n",size);
}
return 0;
}
可以通过 fseek() 函数获取
#include
int main ()
{
FILE * pFile=NULL;
long size;
pFile = fopen ("myfile.txt","rb");
if (pFile==NULL)
perror ("Error opening file");
else
{
fseek (pFile, 0, SEEK_END);
size=ftell (pFile);
fclose (pFile);
pFile=NULL;
printf ("Size of myfile.txt is: %ld bytes.n",size);
}
return 0;
}
举报