以下方法可能因C的版本不同而有所不同。具体用时具体调查一下。这里仅提供思路。
* Program:Get the size of file
#include <sys/stat.h> /* For getting the file's size */
/**********************************************************************
** 概要:
** To get file's size
**********************************************************************/
int getFilesize(char *p_filename)
{
int iRtn; /* return value */
struct stat tStatBuf; /* stat struct */
unsigned long lFileSize; /* filesize */
/* get file size*/
iRtn = stat( filename, &tStatBuf );
if( -1 == iRtn )
{
//To deal with error
}
lFileSize = tStatBuf.st_size;
}