
这是一个用于查找文件大小的C程序。
包装印刷厂网站源码适合印刷公司、图文门店、打印店进行区域业务拓展.通过网站展示业务,如特惠印刷楼书,纸杯,报纸书刊,画册,手提袋,信纸信封,海报,户型单,宣传单,等各种印刷品进行区域业务拓展,方便客户找到厂家。 易优cms包装印刷厂网站源码是基于易优cms开发,包含电脑端及移动端,如果需要小程序的话可以购买易优cms小程序插件,网站安装搭建简单,方便运营维护。
算法
Begin
function findfileSize()
Open a file pointer fp in read only mode.
If fp is equals to null then
Print “File not found” and return -1.
Else count the file size.
Close the file.
Put the file pointer at the beginning of the file
Declare a integer variable result and initialize it with the output of the ftell() function.
Close file pointer fp.
Return result.
EndExample
#includeint findfileSize(char f_n[]) { FILE* fp = fopen(f_n, "r"); // opening a file in read mode if (fp == NULL) // checking whether the file exists or not { printf("File Not Found!\n"); return -1; } fseek(fp, 0L, SEEK_END); int res = ftell(fp); //counting the size of the file fclose(fp); //closing the file return res; } int main() { char f_n[] = { "b.txt" }; //file name is “b.txt” whose size is to be determined int result = findfileSize(f_n); if (result != -1) printf("Size of the file is %ld bytes \n", result); //printing the file size return 0; }
输出
Size of the file is 2649 bytes









