I have searched for the answer, but couldn't find anything. I need to use fstat to know a file size. But my file is ifstream.I've tryied rdbuf()->fd(), but gcc says that fd() does not exists. Thanks any help!
I have searched for the answer, but couldn't find anything. I need to use fstat to know a file size. But my file is ifstream.I've tryied rdbuf()->fd(), but gcc says that fd() does not exists. Thanks any help!
Code:int GetFileSize(std::ifstream& File) { File.seekg(0, std::ios::end); return static_cast<int>(File.tellg()); }
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
>I need to use fstat to know a file size.
Another option is to use stat() to get the file size. It takes a filename versus a FILE *.
It works, thanks for the reply!