C++ এ একটি ফাইলের আকার পেতে প্রথমে ফাইলটি খুলুন এবং এটিকে শেষ পর্যন্ত সন্ধান করুন। tell() আমাদেরকে স্ট্রীমের বর্তমান অবস্থান জানাবে, যা হবে ফাইলের বাইটের সংখ্যা।
উদাহরণ
#include<iostream>
#include<fstream>
using namespace std;
int main() {
ifstream in_file("a.txt", ios::binary);
in_file.seekg(0, ios::end);
int file_size = in_file.tellg();
cout<<"Size of the file is"<<" "<< file_size<<" "<<"bytes";
} আউটপুট
Size of the file is 44 bytes