English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
ftell()函数返回指定流的当前文件位置。将文件指针移到文件末尾后,我们可以使用ftell()函数获取文件的总大小。可以使用SEEK_END常量在文件末尾移动文件指针。
语法:
long int ftell(FILE *stream)
程序:ftell.c
#include <stdio.h> #include <conio.h> void main (){ FILE *fp; int length; clrscr(); fp = fopen("file.txt", "r"); fseek(fp, 0, SEEK_END); length = ftell(fp); fclose(fp); printf("حجم الملف: %d bytes", length); getch(); }
الإخراج:
حجم الملف: 21 byte