C语言_获取文件大小
C语言_获取文件大小
int getFileSize(char * fileName)
{
if (NULL == fileName)
{
printf("fileName is NULL.\n");
return -1;
}
int size = 0;
FILE * fp = fopen(fileName, "rb");
if (NULL == fp)
{
printf("fopen %s failed.\n", fileName);
return -1;
}
fseek(fp, 0L, SEEK_END); /**将文件指针移动到尾部**/
size = ftell(fp);
fclose(fp);
return size;
}
本文是原创文章,采用 CC BY-NC-ND 4.0 协议,完整转载请注明来自 银河驿站
评论
匿名评论
隐私政策
你无需删除空行,直接评论以获取最佳展示效果