English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The ftell() function returns the current file position of the specified stream. After moving the file pointer to the end of the file, we can use the ftell() function to obtain the total size of the file. We can move the file pointer to the end of the file using the SEEK_END constant.
Syntax:
long int ftell(FILE *stream)
Program: 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("File Size: %d bytes", length); getch(); }
Output:
File Size: 21 bytes