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