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; }
评论区