I have opened a file in binary mode, and doing below operations gives negative value of x. The file that I have opened is ~2.5 GB in size.
infile.seekg(0, ios::end);
__int64 x = infile.tellg();
I needed infile
to read bytes (unsigned chars), so I had defined it as a uifstream
by doing:
typedef basic_ifstream<unsigned char, std::char_traits<unsigned char> > uifstream;
which is basically a standard ifstream, but with unsigned chars
instead of chars
.
EDIT: I am using Visual Studio 2005 and corrected uofstream to uifstream.