Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 03 / getFileSize.cpp
blob: bfea3028be97357fdff1858e8093c30f8e2780b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <fstream>
#include <cstring>
using namespace std;

size_t getFileSize(std::ifstream& file)
{
	size_t currentPosition = file.tellg();

	file.seekg(0, ios::end);
	size_t result = file.tellg();
	file.seekg(currentPosition);
	return result;
}
int main()
{
	ifstream file("ddz.txt");
	std::cout << getFileSize(file) << std::endl;
}